当前位置: 首页>>代码示例>>PHP>>正文


PHP mysql::insert_id方法代码示例

本文整理汇总了PHP中mysql::insert_id方法的典型用法代码示例。如果您正苦于以下问题:PHP mysql::insert_id方法的具体用法?PHP mysql::insert_id怎么用?PHP mysql::insert_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mysql的用法示例。


在下文中一共展示了mysql::insert_id方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: insert

 /**
  * 插入数据 支持批量插入
  * @param  boolean $replace 是否替换插入
  * @return 返回插入主键值 如没有则为影响行数 出错返回false
  */
 public function insert($replace = false)
 {
     $this->sql = ($replace ? 'REPLACE' : 'INSERT') . ' INTO ' . $this->_parseTable() . $this->_parseData('insert');
     $query = $this->query($this->sql);
     $id = $this->db->insert_id();
     return empty($id) ? $this->db->affected_rows() : $id;
 }
开发者ID:baiy,项目名称:mysql_slow_query_log_import_db,代码行数:12,代码来源:Mysql.php

示例2: insertPageuserinfo

 /**
  * 网页用户授权,用户信息插入数据库
  */
 public static function insertPageuserinfo($userinfo)
 {
     $db = new mysql();
     $db->connect(DBHOST, DBUSER, DBPASSWORD, DBNAME);
     $sql = "insert into users\n                    (`openid`,`nickname`,`sex`,`language`,`city`,`province`,`country`,`headimgurl`) \n                values(\n                    \n                    '" . $userinfo['openid'] . "',\n                    '" . $userinfo['nickname'] . "',\n                    '" . $userinfo['sex'] . "',\n                    '" . $userinfo['language'] . "',\n                    '" . $userinfo['city'] . "',\n                    '" . $userinfo['province'] . "',\n                    '" . $userinfo['country'] . "',\n                    '" . $userinfo['headimgurl'] . "'\n                )";
     $db->query($sql);
     $userid = $db->insert_id();
     if ($userid) {
         return $userid;
     } else {
         return false;
     }
 }
开发者ID:heshaohua,项目名称:CTNewMedia,代码行数:16,代码来源:usermanage.lib.php

示例3: logRequest

 /**
  * 记录微信发送的请求
  * @param $request 微信发送的请求数组
  * @return 返回刚刚插入的id, 失败返回false
  */
 public static function logRequest($request)
 {
     $db = new mysql();
     $db->connect(DBHOST, DBUSER, DBPASSWORD, DBNAME);
     $message = json_encode($request);
     $sql = "insert into messages(`message`) values('" . $message . "')";
     $db->query($sql);
     $messageid = $db->insert_id();
     return $messageid ? $messageid : false;
 }
开发者ID:heshaohua,项目名称:CTNewMedia,代码行数:15,代码来源:wechatrequest.lib.php

示例4: synlogin

 function synlogin($user)
 {
     global $timestamp, $uc_key;
     list($winduid, $windid, $windpwd) = explode("\t", $this->base->strcode($user, false));
     header('P3P: CP="CURa ADMa DEVa PSAo PSDo OUR BUS UNI PUR INT DEM STA PRE COM NAV OTC NOI DSP COR"');
     require_once "../../config/db.config.php";
     require_once "../../app/include/mysql.class.php";
     require_once "../../app/include/public.function.php";
     require_once "../../data/plus/config.php";
     $ip = fun_ip_get();
     $time = time();
     if ($config[sy_pw_type] == "pw_center") {
         $db = new mysql($db_config['dbhost'], $db_config['dbuser'], $db_config['dbpass'], $db_config['dbname'], ALL_PS, $db_config['charset']);
         $user_query = $db->query("SELECT * FROM {$db_config['def']}member WHERE `username`='{$windid}'");
         while ($userrs = $db->fetch_array($user_query)) {
             $userinfo = $userrs;
         }
         //判断是否是重名用户
         if ($userinfo["uid"] > 0) {
             if ($userinfo["pw_repeat"] != "1") {
                 //判断账户名密码是否一致
                 if ($userinfo["password"] == md5($windpwd . $userinfo[salt])) {
                     $db->query("UPDATE {$db_config['def']}member SET `pwuid`='{$winduid}' WHERE `uid`='{$userinfo['uid']}'");
                     $this->unset_cookie();
                     $this->add_cookie($userinfo[uid], $userinfo[username], $userinfo[salt], $userinfo[email], $userinfo[password]);
                 } else {
                     //不一致标注为重名用户
                     $db->query("UPDATE {$db_config['def']}member SET `pw_repeat`='1' WHERE `uid`='{$userinfo['uid']}'");
                 }
             }
         } else {
             //用户不存在 新建一个用户
             $salt = substr(uniqid(rand()), -6);
             $pass = md5($windpwd . $salt);
             $db->query("INSERT INTO {$db_config['def']}member SET `username`='{$windid}',`password`='{$pass}',`salt`='{$salt}',`usertype`='1',`reg_ip`='{$ip}',`reg_date`='{$time}',`pwuid`='{$winduid}'");
             $uid = $db->insert_id();
             $db->query("INSERT INTO {$db_config['def']}resume SET `uid`='" . $uid . "'");
             $db->query("INSERT INTO {$db_config['def']}member_statis SET `uid`='" . $uid . "'");
             $this->unset_cookie();
             $this->add_cookie($winduid, $windid, $salt, "", $pass);
         }
     }
 }
开发者ID:justinyaoqi,项目名称:qyhr,代码行数:43,代码来源:class_User.php

示例5: synlogin

 function synlogin($get, $post)
 {
     if (!API_SYNLOGIN) {
         return API_RETURN_FORBIDDEN;
     }
     header('P3P: CP="CURa ADMa DEVa PSAo PSDo OUR BUS UNI PUR INT DEM STA PRE COM NAV OTC NOI DSP COR"');
     require_once "../../data/db.config.php";
     require_once "../../include/mysql.class.php";
     require_once "../../include/public.function.php";
     require_once "../../plus/config.php";
     $ip = fun_ip_get();
     $time = time();
     if ($config[sy_uc_type] == "uc_center") {
         $db = new mysql($db_config['dbhost'], $db_config['dbuser'], $db_config['dbpass'], $db_config['dbname'], ALL_PS, $db_config['charset']);
         $user_query = $db->query("SELECT * FROM {$db_config['def']}member WHERE `username`='{$get['username']}'");
         while ($userrs = $db->fetch_array($user_query)) {
             $userinfo[] = $userrs;
         }
         if ($config[sy_onedomain] != "") {
             $weburl = str_replace("http://www", "", $config[sy_onedomain]);
         } elseif ($config[sy_indexdomain] != "") {
             $weburl = str_replace("http://www", "", $config[sy_indexdomain]);
         } else {
             $weburl = str_replace("http://www", "", $config[sy_weburl]);
         }
         if (is_array($userinfo)) {
             $uid = $userinfo[0][uid];
             $certokquery = $db->query("SELECT * FROM {$db_config['def']}company_cert where `uid`='{$uid} ' and `type`='1'");
             while ($certrow = $db->fetch_array($certokquery)) {
                 $certstatus = $certrow[status];
             }
             if ($userinfo[0][username] == $get[username] && $userinfo[0][name_repeat] != "1") {
                 $this->unset_cookie($weburl);
                 if ($userinfo[0][password] == $get[password]) {
                     if ($certstatus == "1" || $config[user_status] != "1" || $userinfo[0][usertype] == "2") {
                         $this->add_cookie($weburl, $userinfo[0][uid], $userinfo[0][username], $userinfo[0][salt], $userinfo[0][email], $userinfo[0][password], $userinfo[0][usertype]);
                     }
                 } else {
                     $db->query("UPDATE {$db_config['def']}member SET `password`='{$get['password']}',`email`='{$get['email']}',`salt`='{$get['salt']}' WHERE `uid`='{$uid}'");
                     if ($certstatus == "1" || $config[user_status] != "1") {
                         $this->add_cookie($weburl, $userinfo[0][uid], $userinfo[0][username], $get[salt], $get[email], $get[password], $userinfo[0][usertype]);
                     }
                 }
                 $db->query("UPDATE {$db_config['def']}member SET `login_ip`='{$ip}',`login_date`='{$time}',`login_hits`=`login_hits`+1 where `uid`='{$uid}'");
             }
         } else {
             $db->query("INSERT INTO {$db_config['def']}member SET `username`='{$get['username']}',`password`='{$get['password']}',`email`='{$get['email']}',`salt`='{$get['salt']}',`usertype`='1',`reg_ip`='{$ip}',`reg_date`='{$time}'");
             $uid = $db->insert_id();
             $db->query("INSERT INTO {$db_config['def']}resume SET `uid`='" . $uid . "'");
             $db->query("INSERT INTO {$db_config['def']}member_statis SET `uid`='" . $uid . "'");
             $randstr = rand(10000000, 99999999);
             $db->query("INSERT INTO {$db_config['def']}company_cert SET `status`='0',`step`='1',`check`='{$get['email']}',`check2`='{$randstr}',`ctime`='" . mktime() . "',`type`='1',`uid`='" . $uid . "'");
             $this->unset_cookie($weburl);
             if ($config[user_status] != "1") {
                 $this->add_cookie($weburl, $uid, $get[username], $get[salt], $get[email], $get[password]);
             }
         }
     }
 }
开发者ID:keyu199314,项目名称:php,代码行数:59,代码来源:uc.php

示例6: synlogin

 function synlogin($get, $post)
 {
     if (!API_SYNLOGIN) {
         return API_RETURN_FORBIDDEN;
     }
     header('P3P: CP="CURa ADMa DEVa PSAo PSDo OUR BUS UNI PUR INT DEM STA PRE COM NAV OTC NOI DSP COR"');
     //TODO:暂时不知道如何改成PLUS_PATH
     require_once $this->appdir . "config/db.config.php";
     require_once $this->appdir . "app/include/mysql.class.php";
     require_once $this->appdir . "app/include/public.function.php";
     require_once dirname(dirname(dirname(__FILE__))) . "/data/plus/config.php";
     //$ip = fun_ip_get();
     $time = time();
     if ($config[sy_uc_type] == "uc_center") {
         $db = new mysql($db_config['dbhost'], $db_config['dbuser'], $db_config['dbpass'], $db_config['dbname'], ALL_PS, $db_config['charset']);
         $user_query = $db->query("SELECT * FROM {$db_config['def']}member WHERE `username`='{$get['username']}'");
         while ($userrs = $db->fetch_array($user_query)) {
             $userinfo[] = $userrs;
         }
         if ($config[sy_onedomain] != "") {
             $weburl = "." . $config[sy_onedomain];
         } else {
             $weburl = str_replace("http://www", "", $config[sy_weburl]);
         }
         if (is_array($userinfo)) {
             $uid = $userinfo[0][uid];
             $certokquery = $db->query("SELECT * FROM {$db_config['def']}company_cert where `uid`='{$uid} ' and `type`='1'");
             while ($certrow = $db->fetch_array($certokquery)) {
                 $certstatus = $certrow[status];
             }
             //$pass = md5($userinfo[0][password].$get[salt]);
             if ($userinfo[0][username] == $get[username] && $userinfo[0][name_repeat] != "1") {
                 $this->unset_cookie($weburl);
                 if ($userinfo[0][password] == $get[password]) {
                     if ($certstatus == "1" || $config[user_status] != "1" || $userinfo[0][usertype] == "2") {
                         $this->add_cookie($weburl, $userinfo[0][uid], $userinfo[0][username], $userinfo[0][salt], $userinfo[0][email], $userinfo[0][password], $userinfo[0][usertype]);
                     }
                 } else {
                     $db->query("UPDATE {$db_config['def']}member SET `password`='{$get['password']}',`email`='{$get['email']}',`salt`='{$get['salt']}' WHERE `uid`='{$uid}'");
                     if ($certstatus == "1" || $config[user_status] != "1") {
                         $this->add_cookie($weburl, $userinfo[0][uid], $userinfo[0][username], $get[salt], $get[email], $get[password], $userinfo[0][usertype]);
                     }
                 }
                 $db->query("UPDATE {$db_config['def']}member SET `login_ip`='{$ip}',`login_date`='{$time}',`login_hits`=`login_hits`+1 where `uid`='{$uid}'");
             }
         } else {
             //创建用户但是无会员身份(usertype)
             $db->query("INSERT INTO {$db_config['def']}member SET `username`='{$get['username']}',`password`='{$get['password']}',`email`='{$get['email']}',`salt`='{$get['salt']}',`reg_ip`='{$ip}',`reg_date`='{$time}',`usertype`='0'");
             $uid = $db->insert_id();
         }
     }
 }
开发者ID:justinyaoqi,项目名称:qyhr,代码行数:52,代码来源:uc.php

示例7: step5

function step5($data)
{
    if ($_POST['meta_name'] == "" || $_POST['alli_tag'] == "" || $_POST['alli_name'] == "" || $_POST['user_name'] == "" || $_POST['user_password'] == "" || $_POST['user_coords1'] == "" || $_POST['user_coords2'] == "") {
        return "Du musst alle Felder ausfüllen.";
    }
    echo "<div style=\"border:1px #000000 solid;width:400px;padding:3px;\"><b>Schritt 5: Abschlu&szlig; der Installation</b><div style=\"text-align:left\">";
    $t =& $_SESSION['install']['mysql'];
    $file = @fopen("../accdata.php", "w");
    if (!$file) {
        echo "<div style=\"color:#800000\">Die Datei accdata.php konnte nicht zum schreiben &ouml;ffnen. Trage die Mysqldaten bitte nachtr&auml;glich ein.</div>";
    } else {
        fwrite($file, "<?php\n        // Account Daten\n        \$db_info['host'] = '" . $t['host'] . "';\n        \$db_info['user'] = '" . $t['username'] . "';\n        \$db_info['password'] = '" . $t['password'] . "';\n        \$db_info['dbname'] = '" . $t['database'] . "';\n        \$pfadzumtick = '" . $_SESSION['install']['tic_adress'] . "'; // Der Schrägstrich am Ende ist wichtig!\n\n        \$tic_status = array('" . implode("', '", $GLOBALS['status']) . "');\n        \$tic_version = array(" . implode(", ", $GLOBALS['version']) . ");\n    ?>");
        fclose($file);
        @chmod("../accdata.php", 0777);
    }
    $mysql = new mysql(array('host' => $t['host'], 'user' => $t['username'], 'password' => $t['password'], 'dbname' => $t['database']));
    unset($t);
    if (isset($_SESSION['install']['tables'])) {
        include "sql.php";
        foreach ($_SESSION['install']['tables'] as $table) {
            $mysql->multiquery($sqlquery[$table]) or die($mysql->error(__FILE__, __LINE__));
        }
    }
    $mysql->insert("gn4meta", "name, sysmsg", "'" . $_POST['meta_name'] . "', 'Wenn dieser Text zu lesen ist dann ist leuft der TIC diese Nachricht kann unter Managment geändert werden.'") or die($mysql->error(__FILE__, __LINE__));
    $ticid = $mysql->insert_id();
    $mysql->insert("gn4vars", "name, value, ticid", "'lastscanclean', '" . date("H:n d.m.Y.") . "', '" . $ticid . "'") or die($mysql->error(__FILE__, __LINE__));
    $mysql->insert("gn4vars", "name, value, ticid", "'forumpriority', '0', '" . $ticid . "'") or die($mysql->error(__FILE__, __LINE__));
    $mysql->insert("gn4vars", "name, value, ticid", "'lasttick', '" . date("H:n:s") . "', '" . $ticid . "'") or die($mysql->error(__FILE__, __LINE__));
    $mysql->insert("gn4vars", "name, value, ticid", "'style', '../gnstyle', '" . $ticid . "'") or die($mysql->error(__FILE__, __LINE__));
    $mysql->insert("gn4vars", "name, value, ticid", "'attplaner', 'aktiv', '" . $ticid . "'") or die($mysql->error(__FILE__, __LINE__));
    $mysql->insert("gn4vars", "name, value, ticid", "'botpw', '', '" . $ticid . "'") or die($mysql->error(__FILE__, __LINE__));
    $mysql->insert("gn4vars", "name, value, ticid", "'tickdauer', '15', '" . $ticid . "'") or die(mysql_error(__FILE__, __LINE__));
    $mysql->insert("gn4allianzen", "ticid, name , tag", "'" . $ticid . "', '" . $_POST['alli_name'] . "', '" . $_POST['alli_tag'] . "'") or die($mysql->error(__FILE__, __LINE__));
    $alli_id = $mysql->insert_id();
    $mysql->insert("gn4accounts", "ticid, name, passwort, galaxie, planet, rang, allianz", "'" . $ticid . "', '" . $_POST['user_name'] . "', '" . md5($_POST['user_password']) . "', '" . $_POST['user_coords1'] . "', '" . $_POST['user_coords2'] . "', '5', '" . $alli_id . "'") or die($mysql->error(__FILE__, __LINE__));
    echo "Die Installation wurde erfolgreich abgeschlossen.<br />Bitte l&ouml;sche den Ordner installer vom Server.<br />Danach kannst du dich <a href=\"../index.php\">hier</a> mit deinen Accountdaten einloggen.</div>";
    return "";
}
开发者ID:albertlast,项目名称:ticenter_tic,代码行数:38,代码来源:steps.php


注:本文中的mysql::insert_id方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。