本文整理匯總了PHP中Illuminate\Database\Query\Builder::insertGetId方法的典型用法代碼示例。如果您正苦於以下問題:PHP Builder::insertGetId方法的具體用法?PHP Builder::insertGetId怎麽用?PHP Builder::insertGetId使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Illuminate\Database\Query\Builder
的用法示例。
在下文中一共展示了Builder::insertGetId方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: insert
/**
* 插入記錄
* @param array $obj
* @return bool|array 成功返回帶id的對象,否則返回false
*/
function insert($obj)
{
$retId = $this->operator->insertGetId($obj);
if ($retId) {
$obj[$this->pkey] = $retId;
}
return $obj;
}
示例2: insertGetId
/**
* 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;
}
示例3: insertGetId
/**
* 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);
}
示例4: insertGetId
/**
* 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;
}
示例5: insertGetId
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;
}