本文整理匯總了PHP中DBObject::hasErrno方法的典型用法代碼示例。如果您正苦於以下問題:PHP DBObject::hasErrno方法的具體用法?PHP DBObject::hasErrno怎麽用?PHP DBObject::hasErrno使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類DBObject
的用法示例。
在下文中一共展示了DBObject::hasErrno方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: die
die(json_encode($json));
}
$db = new DBObject(CURRENT_DB);
$username = $db->escape($_POST['username']);
$timestamp = Crypto::get_timestamp();
$encpass = Crypto::encrypt_password($_POST['userpass'], $timestamp[0]);
$regdate = Crypto::create_microdate($timestamp);
// $sql = "INSERT INTO userinfo(username, userpass, regdate) VALUES(?, ?, ?)";
$sql = "INSERT INTO userinfo(username, userpass, regdate) VALUES(?username:s, ?userpass:s, ?regdate:s)";
sleep(1);
// $query = $db->prepare($sql);
// $query->bind_param('sss', $username, $encpass, $regdate);
// $db->execute($query);
$db->prepare($sql);
$db->bind(array("username" => $username, "userpass" => $encpass, "regdate" => $regdate));
$db->execute();
if ($db->hasErrno(0)) {
$json['status'] = 0;
$json['response'] = 'Registration successful!';
// } else if ($db->getErrno() == 1062) {
} else {
if ($db->hasErrno(1062)) {
$json['status'] = 1;
$json['response'] = 'Username already exists in the database!';
} else {
$json['status'] = 3;
$json['response'] = $db->getError();
}
}
die(json_encode($json));
}