當前位置: 首頁>>代碼示例>>PHP>>正文


PHP DbConn::last_insert_id方法代碼示例

本文整理匯總了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);
}
開發者ID:jcheng5,項目名稱:vteer,代碼行數:7,代碼來源:note_helper.php

示例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);
}
開發者ID:jcheng5,項目名稱:vteer,代碼行數:11,代碼來源:user_helper.php

示例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}");
開發者ID:jcheng5,項目名稱:vteer,代碼行數:18,代碼來源:update.php

示例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');
 }
開發者ID:jcheng5,項目名稱:vteer,代碼行數:20,代碼來源:emails.php


注:本文中的DbConn::last_insert_id方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。