insertGetId() public method

Insert a new record and get the value of the primary key.
public insertGetId ( array $values, string $sequence = null ) : integer
$values array
$sequence string
return integer
Exemplo n.º 1
0
 /**
  * 插入记录
  * @param array $obj
  * @return bool|array 成功返回带id的对象,否则返回false
  */
 function insert($obj)
 {
     $retId = $this->operator->insertGetId($obj);
     if ($retId) {
         $obj[$this->pkey] = $retId;
     }
     return $obj;
 }
Exemplo n.º 2
0
 /**
  * insert data and get id
  *
  * @param array  $args     insert data
  * @param string $sequence sequence
  * @return int
  */
 public function insertGetId(array $args, $sequence = null)
 {
     if ($this->dynamic === false) {
         return $this->query->insertGetId($args, $sequence);
     }
     $result = 0;
     if (count($insert = $this->filter($args, $this->schema())) > 0) {
         $result = $this->query->insertGetId($insert, $sequence);
     }
     if ($this->proxy === true) {
         // autoincrement 가 primary key 일 경우 처리 할 것은?
         $this->getProxyManager()->insert($args);
     }
     return $result;
 }
Exemplo n.º 3
0
 /**
  * Insert a new record and get the value of the primary key.
  *
  * @param array $values
  * @param string $sequence
  * @return int 
  * @static 
  */
 public static function insertGetId($values, $sequence = null)
 {
     return \Illuminate\Database\Query\Builder::insertGetId($values, $sequence);
 }
Exemplo n.º 4
0
 /**
  * Insert a new record and get the value of the primary key.
  *
  * @param  array  $values
  * @param  string $sequence
  *
  * @return int
  */
 public function insertGetId(array $values, $sequence = null)
 {
     $result = parent::insertGetId($values, $sequence);
     $this->handler->setBuilder($this)->setValues($values)->setSqlOperation('insertGetId')->invalidateQuery('insertGetId');
     return $result;
 }
Exemplo n.º 5
0
 public function insertGetId(array $values, $sequence = null)
 {
     if ($this->needFlushCache()) {
         // 清空表级缓存
         $meta = $this->getMeta();
         $meta->flush($this->db(), $this->model->table());
     }
     $id = parent::insertGetId($values, $sequence);
     if ($this->needFlushCache()) {
         $key = $this->buildRowCacheKey([$id])[$id];
         $this->getCache()->del([$key]);
     }
     return $id;
 }
Exemplo n.º 6
0
 /**
  * Insert a new record and get the value of the primary key.
  *
  * @param  array  $values
  * @param  string $sequence
  *
  * @return int
  */
 public function insertGetId(array $values, $sequence = null)
 {
     $result = parent::insertGetId($values, $sequence);
     $this->handler->setBuilder($this)->invalidateQuery(Reflector::QUERY_TYPE_INSERT, $values);
     return $result;
 }