本文整理汇总了PHP中unknown_type::lastInsertId方法的典型用法代码示例。如果您正苦于以下问题:PHP unknown_type::lastInsertId方法的具体用法?PHP unknown_type::lastInsertId怎么用?PHP unknown_type::lastInsertId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类unknown_type
的用法示例。
在下文中一共展示了unknown_type::lastInsertId方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: insert
public function insert(array $array = array())
{
if (!empty($array)) {
$this->inject($array);
}
$columns = $this->queryColumns();
$cols = array();
$vals = array();
$params = array();
foreach ($columns as $c) {
if (array_key_exists($c, $this->data)) {
$cols[] = $c;
$vals[] = ':' . $c;
$params[':' . $c] = $this->data[$c];
}
}
if (in_array('created_on', $columns) && !in_array('created_on', $cols)) {
$cols[] = 'created_on';
$vals[] = ':created_on';
$params[':created_on'] = date('Y-m-d H:i:s');
}
$sql = "INSERT INTO " . static::$table . ' (' . implode(', ', $cols) . ') ' . 'VALUES (' . implode(', ', $vals) . ')';
$s = $this->db->prepare($sql);
$check = $s->execute($params);
$this->{static::$primary} = $this->db->lastInsertId(static::$sequence);
return $check;
}
示例2: addSite
/**
* Add a site.. but take care! This works with regex!!!
* @param unknown_type $name
* @param unknown_type $connection
*/
public function addSite($name, $connection)
{
if ($connection->exec("INSERT INTO `learncards`.`config_loginneedlesssites` (`site`) VALUES ('" . $name . "');") > 0) {
$site = new allowedSite();
$site->setName($name);
$site->setId($connection->lastInsertId());
array_push($this->allAllowedSites, $site);
return "Site " . $name . " is successfully added";
} else {
return "A error happend. Nothings changed!";
}
}
示例3: GetInsertID
/**
* (non-PHPdoc)
* @see RedBean/RedBean_Driver#GetInsertID()
*/
public function GetInsertID()
{
return (int) $this->pdo->lastInsertId();
}
示例4: newQuestion
/**
* Create a new question
* @param question $question
* @param unknown_type $connection
*/
public function newQuestion($question, $connection)
{
$connection->exec("INSERT INTO `" . $GLOBALS['dbPrefix'] . "question_question` (`set`, `question`, `mode`) VALUES (" . $this->setid . ", '" . $question->getQuestion() . "', '" . $question->getMode() . "')");
$question->setId($connection->lastInsertId());
array_push($this->questions, $question);
}
示例5: GetInsertID
/**
* (non-PHPdoc)
* @see RedBean/RedBean_Driver#GetInsertID()
*/
public function GetInsertID()
{
$this->connect();
return (int) $this->pdo->lastInsertId();
}