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


PHP Builder::insert方法代码示例

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


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

示例1: __construct

 /**
  * Construct Closet object with owner's uid.
  *
  * @param int $uid
  */
 public function __construct($uid)
 {
     $this->uid = $uid;
     $this->db = DB::table('closets');
     // create a new closet if not exists
     if (!$this->db->where('uid', $uid)->get()) {
         $this->db->insert(['uid' => $uid, 'textures' => '']);
     }
     // load items from json string
     $this->textures = json_decode($this->db->where('uid', $uid)->get()[0]->textures, true);
     $this->textures = is_array($this->textures) ? $this->textures : [];
     $textures_invalid = [];
     // traverse items in the closet
     foreach ($this->textures as $texture) {
         $result = Texture::find($texture['tid']);
         if ($result) {
             // set user custom texture name
             $result->name = $texture['name'];
             // push instances of App\Models\Texture to the bag
             if ($result->type == "cape") {
                 $this->textures_cape[] = $result;
             } else {
                 $this->textures_skin[] = $result;
             }
         } else {
             $textures_invalid[] = $texture['tid'];
             continue;
         }
     }
     // remove invalid textures from closet
     foreach ($textures_invalid as $tid) {
         $this->remove($tid);
     }
     unset($textures_invalid);
 }
开发者ID:printempw,项目名称:blessing-skin-server,代码行数:40,代码来源:Closet.php

示例2: 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

示例3: insert

 /**
  * insert data
  *
  * @param array $args insert data
  * @return bool
  */
 public function insert(array $args)
 {
     if ($this->dynamic === false) {
         return $this->query->insert($args);
     }
     $result = true;
     if (count($insert = $this->filter($args, $this->schema())) > 0) {
         $result = $this->query->insert($insert);
     }
     if ($this->proxy === true) {
         // autoincrement 가 primary key 일 경우 처리 할 것은?
         $this->getProxyManager()->insert($args);
     }
     return $result;
 }
开发者ID:mint-soft-com,项目名称:xpressengine,代码行数:21,代码来源:DynamicQuery.php

示例4: insert

 /**
  * Insert a new record into the database.
  *
  * @param array $values
  * @return bool 
  * @static 
  */
 public static function insert($values)
 {
     return \Illuminate\Database\Query\Builder::insert($values);
 }
开发者ID:satriashp,项目名称:tour,代码行数:11,代码来源:_ide_helper.php

示例5: insert

 private function insert($data)
 {
     foreach (array_chunk($data, 500) as $chunk) {
         $this->builder->insert($chunk);
     }
 }
开发者ID:ifgroup,项目名称:merger,代码行数:6,代码来源:Merger.php

示例6: batchInsert

 /**
  * @param \Illuminate\Database\Query\Builder $builder
  * @param  array                             $data
  */
 protected function batchInsert(\Illuminate\Database\Query\Builder $builder, array $data)
 {
     $builder->getConnection()->transaction(function () use($builder, $data) {
         // Batch in group of 250 entries to prevent "Too many SQL variables" SQL error
         $insertBatchSize = 250;
         $insertBatchCount = ceil(count($data) / $insertBatchSize);
         for ($i = 0; $i < $insertBatchCount; ++$i) {
             $insertedData = array_slice($data, $i * $insertBatchSize, $insertBatchSize);
             $builder->insert($insertedData);
         }
     });
 }
开发者ID:tomzx,项目名称:irc-stats,代码行数:16,代码来源:Processor.php

示例7: insert

 /**
  * Insert a new record into the database.
  *
  * @param  array $values
  *
  * @return bool
  */
 public function insert(array $values)
 {
     $result = parent::insert($values);
     $this->handler->setBuilder($this)->setValues($values)->setSqlOperation('insert')->invalidateQuery('insert');
     return $result;
 }
开发者ID:spiritix,项目名称:lada-cache,代码行数:13,代码来源:QueryBuilder.php

示例8: insert

 public function insert(array $values)
 {
     if ($this->needFlushCache()) {
         // 清空表级缓存
         $meta = $this->getMeta();
         $meta->flush($this->db(), $this->model->table());
         if (!is_array(reset($values))) {
             $values = [$values];
         }
         $toClearIds = [];
         foreach ($values as $value) {
             $toClearIds[] = $value[$this->model->primaryKey()];
         }
         $toClearKeys = $this->buildRowCacheKey($toClearIds);
         $this->getCache()->del(array_values($toClearKeys));
     }
     return parent::insert($values);
 }
开发者ID:angejia,项目名称:pea,代码行数:18,代码来源:QueryBuilder.php


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