/** * 插入记录 * @param array $obj * @return bool|array 成功返回带id的对象,否则返回false */ function insert($obj) { $retId = $this->operator->insertGetId($obj); if ($retId) { $obj[$this->pkey] = $retId; } return $obj; }
/** * 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; }
/** * 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); }
/** * 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; }
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; }
/** * 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; }