本文整理汇总了PHP中Illuminate\Database\ConnectionInterface::table方法的典型用法代码示例。如果您正苦于以下问题:PHP ConnectionInterface::table方法的具体用法?PHP ConnectionInterface::table怎么用?PHP ConnectionInterface::table使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Database\ConnectionInterface
的用法示例。
在下文中一共展示了ConnectionInterface::table方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
protected function run()
{
$config = ['o_cur_version' => Core::version(), 'o_board_title' => '', 'o_board_desc' => '', 'o_time_format' => 'H:i:s', 'o_date_format' => 'Y-m-d', 'o_show_version' => 0, 'o_default_user_group' => 4];
foreach ($config as $name => $value) {
$this->database->table('config')->insert(['conf_name' => $name, 'conf_value' => $value]);
}
}
示例2: save
public function save()
{
// New and changed keys
$changed = array_diff_assoc($this->data, $this->original);
$insertValues = array();
foreach ($changed as $name => $value) {
if (!array_key_exists($name, $this->original)) {
$insertValues[] = array('conf_name' => $name, 'conf_value' => $value);
unset($changed[$name]);
}
}
if (!empty($insertValues)) {
$this->database->table('config')->insert($insertValues);
}
foreach ($changed as $name => $value) {
$this->database->table('config')->where('conf_name', '=', $name)->update(array('conf_value' => $value));
}
// Deleted keys
$deletedKeys = array_keys(array_diff_key($this->original, $this->data));
if (!empty($deletedKeys)) {
$this->database->table('config')->whereIn('conf_name', $deletedKeys)->delete();
}
// No need to cache old values anymore
$this->original = $this->data;
// Delete the cache so that it will be regenerated on the next request
$this->cache->forget('fluxbb.config');
}
示例3: getList
/**
* Retrieve list of locale codes or names keyed by codes.
*
* @param name
* @return mixed
*/
public function getList($name = null)
{
if ($name) {
if (strpos($name, '.') !== false) {
list($column, $path) = explode('.', $name, 1);
$list = $this->conn->table($this->table)->get([$column, 'code']);
return array_pluck($list, $path, 'code');
}
return $this->conn->table($this->table)->lists($name, 'code');
} else {
$codes = $this->conn->table($this->table)->lists('code');
return array_combine($codes, $codes);
}
}
示例4: removeBy
/**
* @param array $fields
*/
public function removeBy(array $fields)
{
if (empty($fields)) {
return;
}
$this->connection->table($this->table)->where($fields)->delete();
}
示例5: retrieveByCredentials
/**
* Retrieve a user by the given credentials.
*
* @param array $credentials
*
* @return AmazonEchoDevice|null
*/
public function retrieveByCredentials(array $credentials)
{
// First we will add each credential element to the query as a where clause.
// Then we can execute the query and, if we found a user, return it in a
// generic "user" object that will be utilized by the Guard instances.
$query = $this->conn->table($this->table);
foreach ($credentials as $key => $value) {
if (!tr_contains($key, 'password')) {
$query->where($key, $value);
}
}
// Now we are ready to execute the query to see if we have an user matching
// the given credentials. If not, we will just return nulls and indicate
// that there are no matching users for these given credential arrays.
$user = $query->first();
return $this->getGenericUser($user);
}
示例6: __construct
public function __construct(ConnectionInterface $connection, $table, array $to_db, array $types, array $scopes)
{
$this->grammar = $connection->getQueryGrammar();
$this->grammar->to_db = $to_db;
$this->to_db = $to_db;
$this->types = $types;
$this->scopes = $scopes;
$this->builder = $connection->table($table);
}
示例7: table
/**
* 주어진 테이블에 질의할 수 있는 QueryBulider를 생성하여 반환한다.
* 두번째 파라메터가 true로 지정되면 해당 테이블에 dynamic field가 적용된 테이블로 간주하고, 질의한다.
*
* @param string $table 질의할 대상 table, null일 경우 Repository에 지정된 기본 테이블이 사용된다.
* @param bool $useDynamic 질의할 때 Xpressengine의 dynamicField를 사용할 것인지의 여부
*
* @return Builder
*/
protected function table($table = null, $useDynamic = null)
{
$table = $table === null ? $this->mainTable : $table;
$useDynamic = $useDynamic === null ? $this->isDynamic : $useDynamic;
if ($useDynamic) {
return $this->connection->dynamic($table);
} else {
return $this->connection->table($table);
}
}
示例8: aggregateInterval
/**
* @param string $func
* @param string $column
* @param \anlutro\LaravelRepository\CriteriaInterface[] $criteria
* @return array
*/
protected function aggregateInterval($func, $column, array $criteria = [])
{
$query = $this->db->table($this->model->getTable());
$this->interval->applyQuery($query);
array_map(function ($criteria) use($query) {
$criteria->apply($query);
}, $criteria);
$expression = $this->db->raw("{$func}({$column}) as `__aggregate__`");
$query->addSelect($expression);
return $this->interval->parse($query->get(), $this->start, $this->end);
}
示例9: append
/**
* Appends the message stream to the event store.
*
* @param mixed $identifier The aggregate identifier.
* @param DomainEventStreamInterface $stream The stream of domain messages.
* @throws LaravelStoreException When something went wrong
* during persistence.
* @return void
*/
public function append($identifier, DomainEventStreamInterface $stream)
{
// No-op to ensure that an error will be thrown early if the ID
// is not something that can be converted to a string.
(string) $identifier;
try {
$this->connection->beginTransaction();
// Make the domain messages database friendly..
$records = $this->streamSerializer->serialize($stream);
// Now its time to persist them..
foreach ($records as $record) {
$this->connection->table($this->tableName)->insert($record);
}
$this->connection->commit();
} catch (\Exception $exception) {
// Oops, something went wrong
$this->connection->rollBack();
$message = 'Error while persisting the domain events';
throw new LaravelStoreException($message, $exception);
}
}
示例10: appendEvent
/**
* Appends an event to the event store
*/
private function appendEvent(DomainMessage $event)
{
$this->connection->table($this->table)->insert(['uuid' => (string) $event->getId(), 'playhead' => (int) $event->getPlayhead(), 'metadata' => $this->serialize($event->getMetadata()), 'payload' => $this->serialize($event->getPayload()), 'recorded_on' => $event->getRecordedOn()->toString(), 'type' => $event->getType()]);
}
示例11: removeForRange
/**
* Remove value for a key for a given date range.
*
* @param string $key Counter key.
* @param \DateTime $start Start date.
* @param \DateTime $end End date.
* @return void
*/
public function removeForRange($key, \DateTime $start, \DateTime $end)
{
$this->connection->table($this->table)->where('key', $key)->where('start', $start)->where('end', $end)->delete();
}
示例12: queryPointerTable
/**
* Start a query to the pointer table
* @return \Illuminate\Database\QueryBuilder
*/
public function queryPointerTable()
{
return $this->connection->table($this->config->get("mycelium.database.prefix") . "pointers");
}
示例13: set
/**
* TODO: Method set Description
*
* @param $key
* @param $value
*/
public function set($key, $value)
{
$query = $this->database->table('settings')->where('key', $key);
$method = $query->exists() ? 'update' : 'insert';
$query->{$method}(compact('key', 'value'));
}
示例14: run
protected function run()
{
$user = ['username' => $this->get('username'), 'password' => $this->hasher->make($this->get('password')), 'email' => $this->get('email'), 'group_id' => 1, 'registration_ip' => '127.0.0.1'];
$this->database->table('users')->insert($user);
}
示例15: createModel
/**
* @return \Illuminate\Database\Query\Builder
*/
private function createModel()
{
return $this->conn->table($this->table);
}