当前位置: 首页>>代码示例>>PHP>>正文


PHP Connection::table方法代码示例

本文整理汇总了PHP中Illuminate\Database\Connection::table方法的典型用法代码示例。如果您正苦于以下问题:PHP Connection::table方法的具体用法?PHP Connection::table怎么用?PHP Connection::table使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Illuminate\Database\Connection的用法示例。


在下文中一共展示了Connection::table方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: append

 /**
  * @param EventStreamInterface $eventStream
  * @return void
  * @throws SerializationException
  */
 public function append(EventStreamInterface $eventStream)
 {
     $events = collect(iterator_to_array($eventStream))->map(function ($event) {
         /** @var EventInterface $event */
         return ['aggregate_root_id' => (string) $event->getAggregateRootId(), 'type' => get_class($event), 'payload' => $this->serializer->serialize($event)];
     });
     $this->db->table('events')->insert($events->toArray());
 }
开发者ID:desmart,项目名称:laravel-event-sourcing,代码行数:13,代码来源:DbEventStore.php

示例2: checkIfHAshIsUnique

 /**
  * @param $table
  * @param $field
  * @param $hash
  * @param $min_length
  * @param $max_length
  * @return string
  */
 private function checkIfHAshIsUnique($table, $field, $hash, $min_length, $max_length)
 {
     if (!$this->db->table($table)->where($field, '=', $hash)->get()) {
         return $hash;
     } else {
         return $this->makeHAsh($table, $field, true, $min_length, $max_length);
     }
 }
开发者ID:raccoonsoftware,项目名称:Blogify,代码行数:16,代码来源:Blogify.php

示例3: getNickId

 /**
  * @param \Illuminate\Database\Connection $db
  * @param int                             $channelId
  * @param string                          $nick
  * @return int
  */
 protected function getNickId(Connection $db, $channelId, $nick)
 {
     $targetNick = $db->table('nicks')->select('id')->where('channel_id', '=', $channelId)->where('nick', '=', $nick)->first();
     if ($targetNick) {
         return $targetNick['id'];
     } else {
         return $db->table('nicks')->insertGetId(['channel_id' => $channelId, 'nick' => $nick]);
     }
 }
开发者ID:tomzx,项目名称:irc-stats,代码行数:15,代码来源:Parser.php

示例4: run

 public function run()
 {
     $this->database->table(DbEventStore::TABLE)->truncate();
     $startTaskList = new StartTaskListCommand(['Eat cake', 'Walk cake off', 'Rinse and repeat']);
     $this->service->handleStartTaskListCommand($startTaskList);
     $startTaskList = new StartTaskListCommand(['Read: Learn DDD', 'Read: Implementing DDD', 'Read: The data model resource book volume 1', 'Read: The data model resource book volume 2']);
     $this->service->handleStartTaskListCommand($startTaskList);
     $this->command->getOutput()->writeln("<info>Seeded:</info> Task Lists!");
 }
开发者ID:CristianGiordano,项目名称:event-sourced-tasks,代码行数:9,代码来源:DatabaseSeeder.php

示例5: it_appends_events

 /**
  * @test
  */
 public function it_appends_events()
 {
     $event = new PointsWereAdded(100);
     $stream = new EventStream($event);
     $eventData = ['aggregate_root_id' => 'BarId', 'type' => PointsWereAdded::class, 'payload' => ['amount' => '100']];
     $this->db->table('events')->willReturn($this->queryBuilder);
     $this->serializer->serialize($event)->willReturn(['amount' => '100']);
     $this->queryBuilder->insert([$eventData])->willReturn(true);
     $this->eventStore->append($stream);
 }
开发者ID:desmart,项目名称:laravel-event-sourcing,代码行数:13,代码来源:DbEventStoreTest.php

示例6: untranslatedQuery

 /**
  * Create and return a new query to identify untranslated records.
  *
  * @param string $locale
  * @return \Illuminate\Database\Query\Builder
  */
 protected function untranslatedQuery($locale)
 {
     $table = $this->model->getTable();
     return $this->database->table("{$table} as {$table}")->select("{$table}.id")->leftJoin("{$table} as e", function (JoinClause $query) use($table, $locale) {
         $query->on('e.namespace', '=', "{$table}.namespace")->on('e.group', '=', "{$table}.group")->on('e.item', '=', "{$table}.item")->where('e.locale', '=', $locale);
     })->where("{$table}.locale", $this->defaultLocale)->whereNull("e.id");
 }
开发者ID:waavi,项目名称:translation,代码行数:13,代码来源:TranslationRepository.php

示例7: deleteReserved

 /**
  * Delete a reserved job from the queue.
  *
  * @param  string  $queue
  * @param  string  $id
  * @return void
  */
 public function deleteReserved($queue, $id)
 {
     $this->database->beginTransaction();
     if ($this->database->table($this->table)->lockForUpdate()->find($id)) {
         $this->database->table($this->table)->where('id', $id)->delete();
     }
     $this->database->commit();
 }
开发者ID:timpressive,项目名称:art-auction,代码行数:15,代码来源:DatabaseQueue.php

示例8: getEventsByType

 /**
  * @param string[] $eventTypes
  * @param int $skip
  * @param int $take
  * @return DomainEventStream
  */
 public function getEventsByType($eventTypes, $skip, $take)
 {
     $rows = $this->db->table($this->eventStoreTableName)->select(['uuid', 'playhead', 'metadata', 'payload', 'recorded_on'])->whereIn('type', $eventTypes)->skip($skip)->take($take)->orderBy('recorded_on', 'asc')->get();
     $events = [];
     foreach ($rows as $row) {
         $events[] = $this->deserializeEvent($row);
     }
     return new \SmoothPhp\Domain\DomainEventStream($events);
 }
开发者ID:smoothphp,项目名称:cqrs-es-framework-laravel,代码行数:15,代码来源:LaravelEventStore.php

示例9: newQuery

 /**
  * Create a new query builder instance.
  *
  * @param  $insert  boolean  Whether the query is an insert or not.
  *
  * @return \Illuminate\Database\Query\Builder
  */
 protected function newQuery($insert = false)
 {
     $query = $this->connection->table($this->table);
     if ($this->queryConstraint !== null) {
         $callback = $this->queryConstraint;
         $callback($query, $insert);
     }
     return $query;
 }
开发者ID:jafaripur,项目名称:laravel-comments,代码行数:16,代码来源:DatabaseSettingStore.php

示例10: count

 /**
  * Counts current query.
  *
  * @return int
  */
 public function count()
 {
     $query = $this->query;
     // if its a normal query ( no union and having word ) replace the select with static text to improve performance
     $myQuery = clone $query;
     if (!Str::contains(Str::lower($myQuery->toSql()), 'union') && !Str::contains(Str::lower($myQuery->toSql()), 'having')) {
         $myQuery->select($this->connection->raw("'1' as row_count"));
     }
     return $this->connection->table($this->connection->raw('(' . $myQuery->toSql() . ') count_row_table'))->setBindings($myQuery->getBindings())->count();
 }
开发者ID:GHFernando,项目名称:laravel-datatables,代码行数:15,代码来源:BaseEngine.php

示例11: newQuery

 /**
  * Create a new query builder instance.
  *
  * @return \Illuminate\Database\Query\Builder
  */
 protected function newQuery()
 {
     $query = $this->connection->table($this->table);
     foreach ($this->extraColumns as $key => $value) {
         $query->where($key, '=', $value);
     }
     if ($this->queryConstraint !== null) {
         $callback = $this->queryConstraint;
         $callback($query);
     }
     return $query;
 }
开发者ID:hilmysyarif,项目名称:l4-bootstrap-admin,代码行数:17,代码来源:DatabaseSettingStore.php

示例12: seed

 /**
  * Seed the given connection from the given path.
  *
  * @param  Illuminate\Database\Connection  $connection
  * @param  string  $path
  * @return int
  */
 public function seed(Connection $connection, $path)
 {
     $total = 0;
     foreach ($this->getFiles($path) as $file) {
         $records = $this->files->getRequire($file);
         // We'll grab the table name here, which could either come from the array or
         // from the filename itself. Then, we will simply insert the records into
         // the databases via a connection and fire an event noting the seeding.
         $table = $this->getTable($records, $file);
         $connection->table($table)->delete();
         $connection->table($table)->insert($records);
         $total += $count = count($records);
         // Once we have seeded the table, we will fire an event to let any listeners
         // know the tables have been seeded and how many records were inserted so
         // information can be presented to the developer about the seeding run.
         if (isset($this->events)) {
             $this->events->fire('illuminate.seeding', array($table, $count));
         }
     }
     return $total;
 }
开发者ID:hochanh,项目名称:Bootsoft-Bowling,代码行数:28,代码来源:Seeder.php

示例13: getNextPreviousInternal

 private function getNextPreviousInternal(array $data, $prev = false)
 {
     $primary = $this->getPrimaryKey();
     $primaryFields = array_only($data, $primary);
     $select = $this->db->table($this->table)->select(array_keys($primaryFields))->limit(1);
     $op = $prev ? '<' : '>';
     foreach ($primaryFields as $col => $value) {
         $select->where($col, $op, $value);
         $select->orderBy($col, $prev ?: 'asc');
     }
     return $select;
 }
开发者ID:joegreen0991,项目名称:scaffold,代码行数:12,代码来源:Scaffold.php

示例14: fetchAndCache

 /**
  * Cache all configurations.
  *
  * @return void
  */
 public function fetchAndCache()
 {
     $this->removeCache();
     $configs = $this->cache->rememberForever('cartalyst.config', function () {
         return $this->database->table($this->databaseTable)->get();
     });
     $cachedConfigs = [];
     foreach ($configs as $key => $config) {
         $value = $this->parseValue($config->value);
         $cachedConfigs[$config->item] = $value;
         parent::set($config->item, $value);
     }
     $this->cachedConfigs = $cachedConfigs;
 }
开发者ID:sohailaammarocs,项目名称:lfc,代码行数:19,代码来源:Repository.php

示例15: setUp

 /**
  * setUp
  */
 public function setUp()
 {
     $configs = (include __DIR__ . '/../test_database.php');
     $config = array_get($configs, $this->getConfig());
     $dsn = sprintf('%s:dbname=%s', $config['driver'], $config['database']);
     $pdo = new PDO($dsn, $config['username'], $config['password']);
     $class = $this->getConnectionClass();
     $this->connection = new $class($pdo);
     $this->connection->getSchemaBuilder()->dropIfExists('riders');
     $this->connection->getSchemaBuilder()->dropIfExists('classes');
     $this->connection->getSchemaBuilder()->create('classes', function (Blueprint $table) {
         $table->integer('id')->primary();
         $table->string('name');
     });
     $this->connection->table('classes')->insert([['id' => '1', 'name' => 'class1'], ['id' => '2', 'name' => 'class2']]);
     $this->connection->getSchemaBuilder()->create('riders', function (Blueprint $table) {
         $table->increments('id')->primary();
         $table->integer('class_id')->index();
         $table->foreign('class_id')->references('id')->on('classes')->onUpdate('cascade');
         $table->string('name');
     });
     $this->sut = new ColumnCollectionFactory($this->connection);
 }
开发者ID:shin1x1,项目名称:laravel-table-admin,代码行数:26,代码来源:AbstractColumnCollectionFactoryTest.php


注:本文中的Illuminate\Database\Connection::table方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。