本文整理汇总了PHP中DBObject::bind方法的典型用法代码示例。如果您正苦于以下问题:PHP DBObject::bind方法的具体用法?PHP DBObject::bind怎么用?PHP DBObject::bind使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DBObject
的用法示例。
在下文中一共展示了DBObject::bind方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: die
$json['response'] = "Passwords do not match!";
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));
示例2: DBObject
require_once 'includes/Crypto.php';
require_once 'includes/constants.php';
if (!empty($_POST['username']) && !empty($_POST['userpass'])) {
$json = [];
$db = new DBObject(CURRENT_DB);
// $username = $db->escape($_POST['username']);
$username = $_POST['username'];
// $sql = "SELECT * FROM userinfo WHERE userpass = '$hashpass' AND username = '$username'";
$sql = "SELECT * FROM userinfo WHERE username = ?username:s";
$time = rand(1000 * 1000, 1000 * 500);
usleep($time);
// $query = $db->prepare($sql);
// error_log('query from login: ' . print_r($query, true));
// $query->bind_param('s', $username);
$db->prepare($sql);
$db->bind(array("username" => $username));
$json['status'] = 1;
$json['response'] = 'Invalid username/password!';
foreach ($db->execute() as $row) {
if ($db->getNumrows() > 1) {
$json['status'] = 3;
$json['response'] = 'Duplicate username detected! Please clean the database.';
die(json_encode($json));
}
if ($row['status']) {
$timestamp = Crypto::create_timestamp($row['regdate']);
$hashpass = Crypto::encrypt_password($_POST['userpass'], $timestamp[0]);
error_log($hashpass);
error_log($row['userpass']);
if ($hashpass === $row['userpass']) {
$json['status'] = 0;
示例3: MySessions
<?php
date_default_timezone_set('Asia/Manila');
require_once 'includes/constants.php';
require_once 'includes/MySessions.php';
//DBObject included
require_once 'includes/util.php';
//require_once 'includes/functions.php';
$session = new MySessions(COOKIE_NAME);
$cooking = $session->init();
$db = new DBObject(CURRENT_DB);
$sql = 'SELECT * FROM userinfo WHERE username = ?name:s OR userpass = ?pass:s';
$db->prepare($sql);
$db->bind(array('name' => '001', 'pass' => 'password'));
$db->bind(array('name' => '001'));
foreach ($db->execute(false) as $row) {
error_log('row:' . print_r($row, true));
}
$sample = '002';
$db->bind(array("name" => $sample));
foreach ($db->execute() as $row) {
error_log('row:' . print_r($row, true));
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<!--<base href="http://ldc.spumanila.edu.dev" />-->
<title>Language Development Center</title>
<link rel="stylesheet" href="/css/jquery-ui.min.css">