当前位置: 首页>>代码示例>>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;未经允许,请勿转载。