本文整理汇总了PHP中DbConn::last_insert_id方法的典型用法代码示例。如果您正苦于以下问题:PHP DbConn::last_insert_id方法的具体用法?PHP DbConn::last_insert_id怎么用?PHP DbConn::last_insert_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DbConn
的用法示例。
在下文中一共展示了DbConn::last_insert_id方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: add_note
function add_note($userid, $adminid, $source, $content)
{
$db = new DbConn();
$db->exec('insert into notes (userid, adminid, source, content, created) values (?, ?, ?, ?, ?)', $userid, $adminid, $source, $content, date_create());
$noteId = $db->last_insert_id();
log_event(LOG_NOTE_ADDED, $userid, $noteId);
}
示例2: create_user
function create_user($firstname, $lastname, $email, $password)
{
$db = new DbConn();
if (0 == $db->exec('insert into users (firstname, lastname, email, password) values (?, ?, ?, ?)', $firstname, $lastname, $email, $password)) {
throw new RuntimeException('A database error occurred');
}
$newId = $db->last_insert_id();
log_event(LOG_USER_CREATED, $newId);
schedule_mail($newId, MAIL_INTRO);
return get_user($newId);
}
示例3: DbConn
<?php
require_once 'common.inc';
$id = $_POST['id'];
$subject = $_POST['subject'];
$htmlbody = $_POST['htmlbody'];
$textbody = html_to_plaintext($htmlbody);
$db = new DbConn();
if (!$id) {
# New template
$db->exec('insert into mail_templates () values ()');
$id = $db->last_insert_id();
}
$rows = $db->exec('insert into mail_template_versions (templateid, subject, html, plaintext) values (?, ?, ?, ?)', (int) $id, $subject, $htmlbody, $textbody);
if ($rows != 1) {
throw new RuntimeException("Insertion failed!");
}
redirect("list.php?highlight={$id}");
示例4: upload
function upload()
{
if ($_FILES['file']['error'] !== UPLOAD_ERR_OK) {
echo 'File upload failed';
die($_FILES['file']['error']);
}
$filename = $_FILES['file']['name'];
$filetype = $_FILES['file']['type'];
$filesize = filesize($_FILES['file']['tmp_name']);
$db = new DbConn();
$db->exec('insert into mail_attachments (filename, type, size) values (?, ?, ?)', $filename, $filetype, $filesize);
$fileId = $db->last_insert_id();
$destfile = make_attachment_path($fileId);
if (!move_uploaded_file($_FILES['file']['tmp_name'], $destfile)) {
die('Upload failed');
}
$this->load->view('admin/header');
$this->load->view('admin/mail/uploaded', array('fileid' => $fileId, 'filename' => $filename, 'filesize' => $filesize, 'filetype' => $filetype));
$this->load->view('admin/footer');
}