本文整理汇总了PHP中SQL::LastInsertKey方法的典型用法代码示例。如果您正苦于以下问题:PHP SQL::LastInsertKey方法的具体用法?PHP SQL::LastInsertKey怎么用?PHP SQL::LastInsertKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SQL
的用法示例。
在下文中一共展示了SQL::LastInsertKey方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: catch
} else {
$w["isSPAM"] = -2;
}
} catch (Exception $ex) {
}
}
$db->CreateUpdate(0, 'answers', $w);
$answerID = $db->LastInsertKey();
$db->cmd(0, 'UPDATE questions SET date_action={1},user_action="{2}", count_answers = (SELECT count(*) FROM answers WHERE question=questions.id) WHERE id={0} LIMIT 1', true, array($w["question"], time(), MyUser::id() + 0));
$_SESSION["myuser"]["lastwritten"]["answers"][$answerID] = true;
Karma::RuleAction("CREATE_ANSWER", array("user" => MyUser::id(), "question" => $w["question"], "answer" => $answerID));
Badges::add(4, MyUser::id(), array("question" => $w["question"]));
//Erste Antwort geschrieben
}
}
if (isset($_POST["act"]) and $_POST["act"] == "addComment") {
if (strlen($_POST["comment"]) >= 10 and MyUser::isloggedin()) {
$w = array();
$db = new SQL(0);
$w["question"] = $_POST["question"] + 0;
$w["answer"] = $_POST["answer"] + 0;
$w["text"] = $_POST["comment"];
$w["created"] = time();
$w["user"] = MyUser::id();
$db->CreateUpdate(0, 'comments', $w);
$a = $db->LastInsertKey();
Badges::add(5, MyUser::id(), array("question" => $w["question"]));
//Erster Kommentar geschrieben
@header("Location: #comment-" . $a);
}
}
示例2: time
$w["date_created"] = time();
$w["date_edited"] = time();
$w["date_action"] = time();
$w["user_action"] = MyUser::id() + 0;
if (!MyUser::isloggedin()) {
$w["author"] = -1;
} elseif (isset($_POST["wiki"]) and $_POST["wiki"] == "1") {
$w["author"] = -2;
} elseif (isset($_POST["ask_anonymously"]) and $_POST["ask_anonymously"] == "1") {
$w["author"] = MyUser::id();
$w["is_anonymous"] = "1";
} else {
$w["author"] = MyUser::id();
}
$db->Create(0, 'questions', $w);
$frageid = $db->LastInsertKey();
if (!isset($_GET["tag"])) {
$_GET["tag"] = "";
}
$g = explode(",", $_GET["tag"] . "," . $_POST["tags"]);
foreach (tags2array($_POST["tags"]) as $a) {
if (trim($a) == "") {
continue;
}
$w3 = array();
$w3["question"] = $frageid;
$w3["tag"] = $a;
$db->CreateUpdate(0, "question_tags", $w3);
}
$_SESSION["myuser"]["lastwritten"]["question"][$frageid] = true;
Karma::RuleAction("CREATE_QUESTION", array("user" => MyUser::id(), "question" => $frageid));
示例3: while
if (Userlist::userexists($_POST["username"])) {
PageEngine::AddErrorMessage("register", "Der Username wird bereits verwendet");
$j = false;
}
if ($j) {
$passwort = "";
$alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz";
while (strlen($passwort) < 6) {
$passwort .= substr($alpha, rand(0, strlen($alpha)), 1);
}
$w = array();
$w["username"] = $_POST["username"];
$w["email_standard"] = strtolower($_POST["email"]);
$w["dt_registered"] = time();
$db->Create(0, "user_list", $w);
$userid = $db->LastInsertKey();
$w2 = array();
$w2["username"] = "user[" . $userid . "]";
$w2["pwd"] = md5($passwort);
$w2["provider"] = "local";
$w2["user"] = $userid;
$db->Create(0, "user_login", $w2);
$mail = new PHPMailer();
$mail->SetFrom('no-reply@' . $_SERVER["HTTP_HOST"], 'Registrierung ' . SiteConfig::val("page/title"));
$mail->AddAddress($_POST["email"], $w["username"]);
$local = PageEngine::html_find("email_register", ".tpl");
$body = file_get_contents($local);
$body = str_replace(array("{{password}}", "{{page_title}}"), array($passwort, SiteConfig::val("page/title", "Q/A Forum")), $body);
$mail->Subject = "Deine Registrierung bei " . SiteConfig::val("page/title");
$mail->AltBody = 'Vielen Dank für Deine Registrierung,
wir schicken Dir nun Deine Zugangsdaten für ' . SiteConfig::val("page/title") . '. Solltest Du diese nicht beantragt haben, dann lösche bitte diese Nachricht umgehend, damit nicht Dritte Deine Identität nutzen können.
示例4: OpenIDAddLogin
}
}
//print_r($_GET);
}
function OpenIDAddLogin($openIdentifier, $data)
{
$userlist = $openIdentifier;
$db = new SQL(0);
$w = array();
$w["username"] = $userlist;
$w["provider"] = "openid";
$w["user"] = MyUser::id();
$db->CreateUpdate(0, 'user_login', $w);
PageEngine::AddSuccessMessage("openid", "Zugriffsart hinzugefügt");
}
function OpenIDRegisterLogin($openIdentifier, $data)
{
$userlist = $openIdentifier;
$db = new SQL(0);
$row = $db->cmdrow(0, 'SELECT * FROM user_login WHERE username="{0}" AND provider="openid" LIMIT 0,1', array($userlist));
if (!isset($row["username"])) {
$db->cmd(0, 'INSERT IGNORE INTO user_list ');
$w = array();
if (isset($data["nickname"])) {
$w["username"] = $data["nickname"] . "#" . rand(0, 99999);
} else {
$w["username"] = "User#" . rand(0, 99999);
}
$w["email_standard"] = $data["email"];
if (isset($data["language"])) {