本文整理汇总了PHP中db_last_id函数的典型用法代码示例。如果您正苦于以下问题:PHP db_last_id函数的具体用法?PHP db_last_id怎么用?PHP db_last_id使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了db_last_id函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: page_admin_images
function page_admin_images($act = "", $id = "")
{
requires_admin();
use_template("admin");
if ($act == "add") {
if (form_file_uploaded("file")) {
$fname = $_FILES["file"]['name'];
db_query("INSERT INTO images (link) VALUES ('')");
$id = db_last_id();
$fname = $id . "." . fileext($fname);
form_file_uploaded_move("file", "img/" . $fname);
db_query("UPDATE images SET link='img/{$fname}' WHERE id=%d", $id);
redir("admin/images");
}
form_start("", "post", " enctype='multipart/form-data' ");
form_file("Файл", "file");
form_submit("Загрузить", "submit");
form_end();
$o = form();
return $o;
}
if ($act == "del") {
$im = db_object_get("images", $id);
@unlink("../{$im->link}");
}
$o = table_edit("images", "admin/images", $act, $id, "", "", "", "image_func");
return $o;
}
示例2: new_item
function new_item($name, $description, $image, $imageProperties)
{
$result = db_query("INSERT INTO Item (id, name, description, image, image_type) VALUES (DEFAULT, '{$name}', '{$description}', '{$image}', '{$imageProperties}')");
if ($result) {
return db_last_id();
}
return $result;
}
示例3: page_admin_menu_page_attach
function page_admin_menu_page_attach($id)
{
$page_title = menu_page_title($id);
db_query("INSERT INTO pages (short) VALUES ('%s')", $page_title);
$page_id = db_last_id();
db_query("UPDATE menu SET page_id=%d WHERE id=%d", $page_id, $id);
redir("admin/edit/pages/content/{$page_id}&back=" . form_post("back"));
}
示例4: createProfile
/**
* Create new profile;
*
* @param : (array) $aProfileFields - `Profiles` table's fields;
* @return : (integer) - profile's Id;
*/
function createProfile(&$aProfileFields)
{
$sFields = null;
// procces all recived fields;
foreach ($aProfileFields as $sKey => $mValue) {
$mValue = process_db_input($mValue, BX_TAGS_VALIDATE, BX_SLASHES_AUTO);
$sKey = process_db_input($sKey, BX_TAGS_STRIP, BX_SLASHES_NO_ACTION);
$sFields .= "`{$sKey}` = '{$mValue}', ";
}
$sFields = preg_replace('/,$/', '', trim($sFields));
$sQuery = "INSERT INTO `Profiles` SET {$sFields}";
$this->query($sQuery);
return db_last_id();
}
示例5: page_admin_images
function page_admin_images($act = "", $id = "")
{
requires_admin();
use_layout("admin");
form_start("", "post", " enctype='multipart/form-data' ");
form_file("Файл", "file");
$caption = "Загрузить картинку";
if ($act == "edit") {
$caption = "Изменить картинку";
}
form_submit($caption, "submit");
form_end();
$upload = form();
if (form_file_uploaded("file")) {
$fname = $_FILES["file"]['name'];
$ext = strtolower(fileext($fname));
if (!($ext == "swf" || $ext == "jpg" || $ext == "gif" || $ext == "png" || $ext == "bmp" || $ext == "jpeg" || $ext == "pdf")) {
$o = "Данный тип файла не является картинкой";
return $o;
} else {
if ($act == "add") {
db_query("INSERT INTO images (link) VALUES ('')");
$id = db_last_id();
} else {
@unlink(db_result(db_query("SELECT link FROM images WHERE id=%d", $id)));
}
$fname = $id . "." . fileext($fname);
form_file_uploaded_move("file", "img/" . $fname);
db_query("UPDATE images SET link='img/{$fname}' WHERE id=%d", $id);
redir("admin/images/edit/{$id}");
}
}
if ($act == "add") {
$o = $upload;
return $o;
}
if ($act == "del") {
$im = db_object_get("images", $id);
@unlink("{$im->link}");
}
$o = table_edit("images", "admin/images", $act, $id, "", "", "", "image_func");
if ($act == 'edit') {
$im = db_object_get("images", $id);
$o .= "<img width=100px src={$im->link}><br>{$upload}";
}
return $o;
}
示例6: zyklusinsert
function zyklusinsert($sar, $ear, $z, $_POST)
{
$x = 1;
$first_id = 0;
for ($i0 = $sar[0]; $i0 <= $ear[0]; $i0++) {
$sm = 1;
$em = 12;
if ($sar[0] == $i0) {
$sm = $sar[1];
}
if ($ear[0] == $i0) {
$em = $ear[1];
}
for ($i1 = $sm; $i1 <= $em; $i1++) {
$st = 1;
$et = date('t', mktime(0, 0, 0, $i1, 1, $i0));
if ($sar[0] == $i0 and $sar[1] == $i1) {
$st = $sar[2];
}
if ($ear[0] == $i0 and $ear[1] == $i1) {
$et = $ear[2];
}
for ($i2 = $st; $i2 <= $et; $i2++) {
if (checkzyklusins($x, $i0, $i1, $i2, $z, $sar)) {
$time = mktime($_POST['stunde'], $_POST['minute'], 0, $i1, $i2, $i0);
db_query("INSERT INTO `prefix_kalender` (`time`,`gid`,`title`,`text`,`recht`) VALUES (" . $time . "," . $first_id . ",'" . escape($_POST['title'], 'string') . "','" . escape($_POST['txt'], 'string') . "','" . escape($_POST['recht'], 'integer') . "')");
if ($first_id == 0) {
$first_id = db_last_id();
db_query("UPDATE `prefix_kalender` SET `gid` = " . $first_id . " WHERE `id` = " . $first_id);
}
}
$x++;
}
}
}
}
示例7: updateLangFile
function updateLangFile($key, $string)
{
$langName = getParam('lang_default');
$langID = db_value("SELECT `ID` FROM `sys_localization_languages` WHERE `Name` = '" . addslashes($langName) . "'");
$keyID = db_value("SELECT `ID` FROM `sys_localization_keys` WHERE `Key` = '" . process_db_input($key) . "'");
if ($keyID) {
db_res("UPDATE `sys_localization_strings` SET `String` = '" . process_db_input($string) . "' WHERE `IDKey`='{$keyID}' AND `IDLanguage`='{$langID}'");
} else {
db_res("INSERT INTO `sys_localization_keys` SET `IDCategory` = 2, `Key` = '" . process_db_input($key) . "'");
db_res("INSERT INTO `sys_localization_strings` SET `IDKey` = " . db_last_id() . ", `IDLanguage` = '{$langID}', `String` = '" . process_db_input($string) . "'");
}
compileLanguage($langID);
}
示例8: sendpm
function sendpm($sid, $eid, $ti, $te, $status = 0)
{
$page = $_SERVER["HTTP_HOST"] . $_SERVER["SCRIPT_NAME"];
// Testen, ob Array. Sonst umwandeln.
if (!is_array($eid)) {
$eid = array($eid);
}
// Alle Emf�nger durchlaufen
foreach ($eid as $empf) {
// PM schreiben und ID speichern
db_query("INSERT INTO `prefix_pm` (`sid`,`eid`,`time`,`titel`,`txt`,`status`) VALUES (" . $sid . "," . $empf . ",'" . time() . "','" . $ti . "','" . $te . "'," . $status . ")");
$last_id = db_last_id();
// Alle Zeiten der letzten PMs abfragen, die nach dem letzten Login des Empf�ngers verschickt wurden
$erg = db_query("SELECT `b`.`time` FROM `prefix_user` AS `a` LEFT JOIN `prefix_pm` AS `b` ON `a`.`id` = `b`.`eid` AND `b`.`id` != " . $last_id . " WHERE `a`.`id` = " . $empf . " AND `a`.`llogin` < `b`.`time`");
// Wenn keine PM gefunden wurde, Email schreiben
if (db_num_rows($erg) == 0) {
// Email-Adresse abfragen und Email verschicken
$mail = db_result(db_query("SELECT `email` FROM `prefix_user` WHERE `id` = " . $empf), 0);
if (!empty($mail)) {
icmail($mail, "Du hast eine neue Nachricht", "Hallo,\ndu hast eben eine Neue Nachricht mit dem Betreff '" . $ti . "' bekommen. Diese Nachricht kannst du nun unter folgender Adresse mit Deinen Logindaten aufrufen: " . $page . "?forum-privmsg-showmsg-" . $last_id . "\n\nWir wünschen Dir noch einen schönen Tag!");
}
}
}
}
示例9: checkNewBlock
function checkNewBlock($iBlockID)
{
$iBlockID = (int) $iBlockID;
$sQuery = "SELECT `Desc`, `Caption`, `Func`, `Content`, `Visible`, `DesignBox` FROM `{$this->sDBTable}` WHERE `ID` = '{$iBlockID}'";
$aBlock = db_assoc_arr($sQuery);
if ($aBlock['Func'] == 'Sample') {
$sQuery = "\n INSERT INTO `{$this->sDBTable}` SET\n `Desc` = '" . addslashes($aBlock['Desc']) . "',\n `Caption` = '" . addslashes($aBlock['Caption']) . "',\n `Func` = '{$aBlock['Content']}',\n `Visible` = '{$aBlock['Visible']}',\n `DesignBox` = '{$aBlock['DesignBox']}',\n `Page` = '{$this->sPage_db}'\n ";
db_res($sQuery);
echo db_last_id();
$this->createCache();
}
}
示例10: escape
// mal kurz nen neuen user anlegen
// mal kurz nen neuen user anlegen
case 'createNewUser':
$msg = '';
if (!empty($_POST['name']) and !empty($_POST['pass']) and !empty($_POST['email']) and chk_antispam('adminuser_create', true)) {
$_POST['name'] = escape($_POST['name'], 'string');
$_POST['recht'] = escape($_POST['recht'], 'integer');
$_POST['email'] = escape($_POST['email'], 'string');
$erg = db_query("SELECT id FROM prefix_user WHERE name = BINARY '" . $_POST['name'] . "'");
if (db_num_rows($erg) > 0) {
$msg = 'Der Name ist leider schon vorhanden!';
} else {
$new_pass = $_POST['pass'];
$passwordHash = user_pw_crypt($new_pass);
db_query("INSERT INTO prefix_user (name,pass,recht,regist,llogin,email)\r\n\t\t VALUES('" . $_POST['name'] . "','" . $passwordHash . "'," . $_POST['recht'] . ",'" . time() . "','" . time() . "','" . $_POST['email'] . "')");
$userid = db_last_id();
db_query("INSERT INTO prefix_userfields (uid,fid,val) VALUES (" . $userid . ",2,'1')");
db_query("INSERT INTO prefix_userfields (uid,fid,val) VALUES (" . $userid . ",3,'1')");
if (isset($_POST['info'])) {
$page = $_SERVER["HTTP_HOST"] . $_SERVER["SCRIPT_NAME"];
$page = str_replace('admin.php', 'index.php', $page);
$tpl = new tpl('user/new_user_email', 1);
$tpl->set('name', $_POST['name']);
$tpl->set('pass', $_POST['pass']);
$tpl->set('page', $page);
$txt = $tpl->get(0);
unset($tpl);
icmail($_POST['email'], 'Admin hat dich angelegt', $txt);
}
$msg = 'Benutzer angelegt <a href="javascript:closeThisWindow()">Fenster schließen</a>';
}
示例11: page_admin_catalog_images
function page_admin_catalog_images($catalog_id = "", $act = "", $id = "")
{
requires_admin();
use_template("admin");
global $tables;
$tables['catalog_images']['weight'] = 1;
$o = "";
if ($act == "edit") {
$o .= "<a href=admin/catalog/images/{$catalog_id}><<Назад</a><br>";
} else {
$catalog = db_object_get("catalog", $catalog_id);
$o .= "<a href=admin/catalog/edit/{$catalog->parent_id}/edit/{$catalog_id}><<Назад</a><br>";
}
if ($act == "del") {
$fname = db_object_get("catalog_images", $id)->image_file;
@unlink("img/upload/catalog/{$fname}");
}
if ($act == "edit") {
form_start("", "post", " enctype='multipart/form-data' ");
form_file("Файл", "file");
form_submit("Загрузить картинку", "submit");
form_end();
$upload = form();
$upload .= "<script>\r\n \$(function() {\r\n\t\t\t\t \$('input[name=submit]').remove();\r\n \$('input[name=file]').change( function() {\r\n\t\t\t\t\t \$('form').submit();\r\n\t });\r\n\t });\r\n\t\t </script>";
$o .= $upload;
if (form_file_uploaded("file")) {
$fname = $_FILES["file"]['name'];
$ext = strtolower(fileext($fname));
if (!($ext == "swf" || $ext == "jpg" || $ext == "gif" || $ext == "png" || $ext == "bmp" || $ext == "jpeg" || $ext == "pdf")) {
$o = "Данный тип файла не является картинкой";
return $o;
} else {
@unlink("img/upload/catalog/" . db_result(db_query("SELECT image_file FROM catalog_images WHERE id=%d", $id)));
$fname = $id . "." . fileext($fname);
form_file_uploaded_move("file", "img/upload/catalog/" . $fname);
db_query("UPDATE catalog_images SET image_file='{$fname}' WHERE id=%d", $id);
redir("admin/catalog/images/{$catalog_id}");
}
}
}
if ($act == "add") {
$_REQUEST['add'] = true;
}
global $table_edit_props;
$table_edit_props->add_redir = false;
$o .= table_edit("catalog_images", "admin/catalog/images/{$catalog_id}", $act, $id, "catalog_id", $catalog_id, "", "on_catalog_image");
if ($act == "add") {
$id = db_last_id();
redir("admin/catalog/images/{$catalog_id}/edit/" . $id);
die;
}
return $o;
}
示例12: _updateLanguage
function _updateLanguage($bInstall, $aLanguage, $iCategoryId = 0)
{
if (empty($iCategoryId)) {
$iCategoryId = (int) db_value("SELECT `ID` FROM `sys_localization_categories` WHERE `Name`='" . $this->_aConfig['language_category'] . "' LIMIT 1");
}
$sPath = $this->_sHomePath . 'install/langs/' . $aLanguage['name'] . '.php';
if (!file_exists($sPath)) {
return false;
}
include $sPath;
if (!(isset($aLangContent) && is_array($aLangContent))) {
return false;
}
//--- Installation ---//
if ($bInstall) {
foreach ($aLangContent as $sKey => $sValue) {
$iLangKeyId = (int) db_value("SELECT `ID` FROM `sys_localization_keys` WHERE `IDCategory`='" . $iCategoryId . "' AND `Key`='" . $sKey . "' LIMIT 1");
if ($iLangKeyId == 0) {
db_res("INSERT INTO `sys_localization_keys`(`IDCategory`, `Key`) VALUES('" . $iCategoryId . "', '" . $sKey . "')");
if (db_affected_rows() <= 0) {
continue;
}
$iLangKeyId = db_last_id();
}
db_res("INSERT IGNORE INTO `sys_localization_strings`(`IDKey`, `IDLanguage`, `String`) VALUES('" . $iLangKeyId . "', '" . $aLanguage['id'] . "', '" . addslashes($sValue) . "')");
}
} else {
foreach ($aLangContent as $sKey => $sValue) {
db_res("DELETE FROM `sys_localization_keys`, `sys_localization_strings` USING `sys_localization_keys`, `sys_localization_strings` WHERE `sys_localization_keys`.`ID`=`sys_localization_strings`.`IDKey` AND `sys_localization_keys`.`Key`='" . $sKey . "'");
}
}
return true;
}
示例13: db_query
$um = $menu->get(1);
if ($menu->get(1) == 'del') {
db_query('DELETE FROM `prefix_poll` WHERE `poll_id` = "' . $_GET['del'] . '"');
db_query('DELETE FROM `prefix_poll_res` WHERE `poll_id` = "' . $_GET['del'] . '"');
}
if ($menu->get(1) == 5) {
db_query('UPDATE `prefix_poll` SET `stat` = "' . $_GET['ak'] . '" WHERE `poll_id` = "' . $_GET['id'] . '"');
}
// A L L E V O T E S W E R D E N A N G E Z E I G T
if (isset($_POST['sub']) and chk_antispam('adminuser_action', true)) {
$_POST['frage'] = escape($_POST['frage'], 'string');
$_POST['poll_recht'] = escape($_POST['poll_recht'], 'integer');
$_POST['vid'] = escape($_POST['vid'], 'integer');
if (empty($_POST['vid'])) {
db_query('INSERT INTO `prefix_poll` (`frage`,`recht`,`stat`,`text`) VALUES ( "' . $_POST['frage'] . '" , "' . $_POST['poll_recht'] . '" , "1" ,"") ');
$poll_id = db_last_id();
$i = 1;
foreach ($_POST['antw'] as $v) {
if (!empty($v)) {
$v = escape($v, 'string');
db_query('INSERT INTO `prefix_poll_res` (`sort`,`poll_id`,`antw`,`res`) VALUES ( "' . $i . '" , "' . $poll_id . '" , "' . $v . '" , "" ) ');
$i++;
}
}
} else {
db_query('UPDATE `prefix_poll` SET frage = "' . $_POST['frage'] . '", recht = "' . $_POST['poll_recht'] . '" WHERE poll_id = "' . $_POST['vid'] . '"');
$i = 1;
foreach ($_POST['antw'] as $k => $v) {
$a = db_count_query("SELECT COUNT(*) FROM `prefix_poll_res` WHERE `poll_id` = " . $_POST['vid'] . " AND `sort` = " . $k);
$v = escape($v, 'string');
if ($a == 0 and $v != '') {
示例14: design
$tpl->set_ar_out($ar, 1);
} else {
// save toipc
$_SESSION['klicktime'] = $dppk_time;
$design = new design($title, $hmenu, 0);
$design->header($load);
if (loggedin()) {
$uid = $_SESSION['authid'];
$erst = escape($_SESSION['authname'], 'string');
db_query("UPDATE `prefix_user` SET `posts` = `posts`+1 WHERE `id` = " . $uid);
} else {
$erst = $xnn;
$uid = 0;
}
db_query("INSERT INTO `prefix_topics` (`fid`, `name`, `erst`, `stat`) VALUES ( " . $fid . ", '" . $topic . "', '" . $erst . "', 1 )");
$tid = db_last_id();
// topic alert
if (!empty($_POST['topic_alert']) and $_POST['topic_alert'] == 'yes' and loggedin()) {
if (0 == db_result(db_query("SELECT COUNT(*) FROM `prefix_topic_alerts` WHERE `uid` = " . $_SESSION['authid'] . " AND `tid` = " . $tid), 0)) {
db_query("INSERT INTO `prefix_topic_alerts` (`tid`,`uid`) VALUES (" . $tid . ", " . $_SESSION['authid'] . ")");
}
}
db_query("INSERT INTO `prefix_posts` (`tid`,`fid`,`erst`,`erstid`,`time`,`txt`) VALUES ( " . $tid . ", " . $fid . ", '" . $erst . "', " . $uid . ", " . $time . ", '" . $txt . "')");
$pid = db_last_id();
db_query("UPDATE `prefix_topics` SET `last_post_id` = " . $pid . " WHERE `id` = " . $tid);
db_query("UPDATE `prefix_forums` SET `posts` = `posts` + 1, `last_post_id` = " . $pid . ", `topics` = `topics` + 1 WHERE `id` = " . $fid);
// toipc als gelesen markieren
$_SESSION['forumSEE'][$fid][$tid] = time();
wd('index.php?forum-showposts-' . $tid, $lang['createtopicsuccessful']);
}
$design->footer();
示例15: insert_table_record
function insert_table_record()
{
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# add a record in the table
#
global $USER_RRN, $dbh, $_FIELDS, $_T_FIELDS;
// if(strlen($lang)==0) { $lang = $_SESSION['table_editor']['lang']; }
// if(strlen($lang)==0) { $lang = $_SESSION['sitelanguage']; }
$sql = 'INSERT INTO ' . MAINSITE_DB . '.`' . EDIT_TABLE_NAME . '` ' . 'SET ';
if (defined('EDIT_TABLE_IS_LAST_USER') && EDIT_TABLE_IS_LAST_USER == true) {
$sql .= '`' . EDIT_TABLE_NAME . '`.`LAST_USER` = ' . (int) $USER_RRN . ', ';
}
for ($i = 0; $i < $_T_FIELDS; $i++) {
$post_name = $_FIELDS[$i]['Field'];
if ($post_name != 'RRN' && $post_name != 'LAST_USER' && $post_name != 'LAST_UPDATE') {
# if is not a reserved field
#
$field_len_info = table_editor_get_field_len_info($_FIELDS[$i]['Type']);
//var_dump($field_len_info);echo '<hr>';
$field_name = 'r_' . $_FIELDS[$i]['Field'];
if ($field_len_info['dec'] > 0) {
# MySQL does not like the comma used as the decimal separator...
#
$value = str_replace(',', '.', $_POST[$post_name]);
}
if ($field_len_info['isSTRING'] == true || $field_len_info['isTEXT'] == true) {
$sql .= '`' . EDIT_TABLE_NAME . '`.`' . $post_name . '` = \'' . mysql_real_escape_string($_POST[$post_name]) . '\', ';
} else {
if ($_FIELDS[$i]['Type'] == 'date') {
$sql .= '`' . EDIT_TABLE_NAME . '`.`' . $post_name . '` = \'' . format_calendar_to_date($_POST[$post_name]) . '\', ';
} elseif ($_FIELDS[$i]['Type'] == 'datetime' || $_FIELDS[$i]['Type'] == 'timestamp') {
$sql .= '`' . EDIT_TABLE_NAME . '`.`' . $post_name . '` = \'' . format_calendar_to_datetime($_POST[$post_name]) . '\', ';
} elseif ((int) $field_len_info['dec'] > 0) {
//$sql .= '`'.EDIT_TABLE_NAME.'`.`'.$post_name.'` = '.number_format($_POST[$post_name], (int)$field_len_info['dec'], '.', '').', ';
$sql .= '`' . EDIT_TABLE_NAME . '`.`' . $post_name . '` = ' . $value . ', ';
} else {
$sql .= '`' . EDIT_TABLE_NAME . '`.`' . $post_name . '` = ' . (int) $_POST[$post_name] . ', ';
}
}
}
}
$sql = substr($sql, 0, -2);
//echo $sql.'<br><br>';
//return;
$sth = db_query($sql, __LINE__, __FILE__);
$RRN = db_last_id($dbh);
#
return $RRN;
}