本文整理汇总了PHP中mysqli_stmt_num_rows函数的典型用法代码示例。如果您正苦于以下问题:PHP mysqli_stmt_num_rows函数的具体用法?PHP mysqli_stmt_num_rows怎么用?PHP mysqli_stmt_num_rows使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了mysqli_stmt_num_rows函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: authenticate_user
function authenticate_user($data)
{
global $db;
$email = $data['email'];
$password = $data['password'];
//getting the salt
$stmt = mysqli_prepare($db, "SELECT salt FROM users WHERE email = ? LIMIT 1");
mysqli_stmt_bind_param($stmt, "s", $email);
mysqli_stmt_execute($stmt);
mysqli_stmt_store_result($stmt);
mysqli_stmt_bind_result($stmt, $salt);
if (mysqli_stmt_num_rows($stmt)) {
mysqli_stmt_fetch($stmt);
$password = hash('sha256', "{$password}" . "{$salt}");
//adding salt to given pass hashing and checking if the resulting hash is the same as the original
mysqli_stmt_close($stmt);
$stmt = mysqli_prepare($db, "SELECT uid, username, email FROM users WHERE email = ? AND password = ?");
mysqli_stmt_bind_param($stmt, "ss", $email, $password);
mysqli_stmt_execute($stmt);
mysqli_stmt_store_result($stmt);
mysqli_stmt_bind_result($stmt, $uid, $username, $email);
if (mysqli_stmt_num_rows($stmt)) {
mysqli_stmt_fetch($stmt);
mysqli_stmt_close($stmt);
$user = ['userid' => $uid, 'username' => $username, 'email' => $email];
return $user;
} else {
return false;
}
} else {
return false;
}
}
示例2: checkrows
function checkrows()
{
include "components/db_connect.php";
$username = $_POST['email'];
$x = "select * from details where email='{$username}'";
$result = mysqli_prepare($con, $x);
mysqli_stmt_execute($result);
mysqli_stmt_store_result($result);
$y = mysqli_stmt_num_rows($result);
include "components/db_disconnect.php";
return $y;
}
示例3: printf
if (mysqli_stmt_prepare($stmt, 'SELECT unknown_column FROM this_table_does_not_exist') || mysqli_stmt_execute($stmt)) {
printf("[041] The invalid SELECT statement is issued on purpose\n");
}
if (-1 !== ($tmp = mysqli_stmt_affected_rows($stmt))) {
printf("[042] Expecting int/-1, got %s/%s\n", gettype($tmp), $tmp);
}
if ($IS_MYSQLND) {
if (false !== ($tmp = mysqli_stmt_store_result($stmt))) {
printf("[043] Expecting boolean/false, got %s\\%s\n", gettype($tmp), $tmp);
}
} else {
if (true !== ($tmp = mysqli_stmt_store_result($stmt))) {
printf("[043] Libmysql does not care if the previous statement was bogus, expecting boolean/true, got %s\\%s\n", gettype($tmp), $tmp);
}
}
if (0 !== ($tmp = mysqli_stmt_num_rows($stmt))) {
printf("[044] Expecting int/0, got %s/%s\n", gettype($tmp), $tmp);
}
if (-1 !== ($tmp = mysqli_stmt_affected_rows($stmt))) {
printf("[045] Expecting int/-1, got %s/%s\n", gettype($tmp), $tmp);
}
mysqli_stmt_close($stmt);
$stmt = mysqli_stmt_init($link);
if (!mysqli_stmt_prepare($stmt, "DROP TABLE IF EXISTS test_mysqli_stmt_affected_rows_table_1") || !mysqli_stmt_execute($stmt)) {
printf("[046] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
}
mysqli_stmt_close($stmt);
if (!is_null($tmp = mysqli_stmt_affected_rows($stmt))) {
printf("[047] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
}
mysqli_close($link);
示例4: login
function login()
{
include_once 'database_conn.php';
// check is form filled
if (isFormFilled()) {
// if not filled, stop
return;
}
$uid = sanitizeData($_POST['username']);
$pswd = sanitizeData($_POST['password']);
$columnLengthSql = "\n\t\t\tSELECT COLUMN_NAME, CHARACTER_MAXIMUM_LENGTH\n\t\t\tFROM INFORMATION_SCHEMA.COLUMNS\n\t\t\tWHERE TABLE_NAME = 'te_users'\n\t\t\tAND (column_name = 'username'\n\t\t\tOR column_name = 'passwd')";
$COLUMN_LENGTH = getColumnLength($conn, $columnLengthSql);
$isError = false;
$errMsg[] = validateStringLength($uid, $COLUMN_LENGTH['username']);
//uid
$errMsg[] = validateStringLength($pswd, $COLUMN_LENGTH['passwd']);
//pswd
for ($i = 0; $i < count($errMsg); $i++) {
if (!($errMsg[$i] === true)) {
echo "{$errMsg[$i]}";
$isError = true;
}
}
//if contain error, halt continue executing the code
if ($isError) {
return;
}
// check is uid exist
$checkUIDSql = "SELECT passwd, salt FROM te_users WHERE username = ?";
$stmt = mysqli_prepare($conn, $checkUIDSql);
mysqli_stmt_bind_param($stmt, "s", $uid);
mysqli_stmt_execute($stmt);
mysqli_stmt_store_result($stmt);
if (mysqli_stmt_num_rows($stmt) <= 0) {
echo "Sorry we don't seem to have that username.";
return;
}
mysqli_stmt_bind_result($stmt, $getHashpswd, $getSalt);
while (mysqli_stmt_fetch($stmt)) {
$hashPswd = $getHashpswd;
$salt = $getSalt;
}
// if exist, then get salt and db hashed password
// create hash based on password
// hash pswd using sha256 algorithm
// concat salt in db by uid
// hash using sha256 algorithm
$pswd = hash("sha256", $salt . hash("sha256", $pswd));
// check does it match with hased password from db
if (strcmp($pswd, $hashPswd) === 0) {
echo "Success login<br/>";
// add session
$_SESSION['logged-in'] = $uid;
// go to url
$url = $_SERVER['REQUEST_URI'];
header("Location: {$url}");
} else {
echo "Fail login<br/>";
}
}
示例5: evalLoggedUser
function evalLoggedUser($con, $id, $u, $p)
{
$sql = "SELECT lastlogin FROM users WHERE id=? AND name=? AND pass=? LIMIT 1";
if ($stmt = mysqli_prepare($con, $sql)) {
mysqli_stmt_bind_param($stmt, "iss", $id, $u, $p);
mysqli_stmt_execute($stmt);
// $query = mysqli_query($conx, $sql);
$numrows = mysqli_stmt_num_rows($stmt);
if ($numrows > 0) {
return true;
}
}
}
示例6: verificaMesGrafico
function verificaMesGrafico($string)
{
include "conf-conexao.php";
include "script-time.php";
// selecione o total de meses quando ano for igua a anoCorrente
$consultaSqlVerificaMes = "SELECT MES FROM tab_dados_grafico WHERE MES LIKE '%{$string}%' AND ANO = {$anoCorrente}";
$stmt = mysqli_prepare($conexao, $consultaSqlVerificaMes);
if ($stmt) {
mysqli_stmt_execute($stmt);
mysqli_stmt_store_result($stmt);
echo mysqli_stmt_num_rows($stmt);
}
}
示例7: obtenerCantidadPorDNI
function obtenerCantidadPorDNI($dni)
{
$conect = conectar();
$sql = "SELECT COUNT(prod.id) as cantidad\n FROM persona as per\n INNER JOIN producto as prod ON (prod.persona_id = per.id)\n WHERE per.dni = ?\n GROUP BY per.dni";
$stmt = $conect->prepare($sql);
$stmt->bind_param('i', $dni);
$stmt->execute();
$stmt->bind_result($cantidad);
$stmt->store_result();
if (mysqli_stmt_num_rows($stmt) > 0) {
$row = mysqli_stmt_fetch($stmt);
$result = array('estado' => true, 'cantidad' => $cantidad);
} else {
$result = array('estado' => false);
}
return $result;
}
示例8: getAllActivitiesByUser
function getAllActivitiesByUser($params)
{
$connection = dbConnect();
$options = ['columns' => 'a.id, ud.nome as demandante, s.sigla,
sa.status, a.titulo, a.data, a.tempo_gasto, a.id_status', 'join' => [['type' => 'INNER JOIN', 'table' => 'setores s', 'columns' => 's.id = a.id_setor'], ['type' => 'INNER JOIN', 'table' => 'status_atividade sa', 'columns' => 'sa.id = a.id_status'], ['type' => 'INNER JOIN', 'table' => 'usuarios ud', 'columns' => 'ud.id = a.id_demandante']], 'where' => ['a.id_responsavel' => $_SESSION['id']], 'order_by' => 'a.data DESC', 'limit' => $params['limit'] . ', ' . $params['offset']];
$sql = buildSelect('atividades a', $options);
$stmt = mysqli_prepare($connection, $sql);
mysqli_stmt_bind_param($stmt, 'i', $_SESSION['id']);
mysqli_stmt_execute($stmt);
mysqli_stmt_store_result($stmt);
mysqli_stmt_bind_result($stmt, $id, $demandante, $sigla, $status, $titulo, $data, $tempo_gasto, $id_status);
$result = [];
while (mysqli_stmt_fetch($stmt)) {
array_push($result, ["id" => $id, "demandante" => $demandante, "sigla" => $sigla, "status" => $status, "titulo" => $titulo, "data" => $data, "tempo_gasto" => $tempo_gasto, "id_status" => $id_status]);
}
$numRows = mysqli_stmt_num_rows($stmt);
mysqli_stmt_close($stmt);
dbClose($connection);
return ['result' => $result, 'numRows' => $numRows];
}
示例9: func_test_mysqli_stmt_num_rows
function func_test_mysqli_stmt_num_rows($stmt, $query, $expected, $offset)
{
if (!mysqli_stmt_prepare($stmt, $query)) {
printf("[%03d] [%d] %s\n", $offset, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
return false;
}
if (!mysqli_stmt_execute($stmt)) {
printf("[%03d] [%d] %s\n", $offset + 1, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
return false;
}
if (!mysqli_stmt_store_result($stmt)) {
printf("[%03d] [%d] %s\n", $offset + 2, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
return false;
}
if ($expected !== ($tmp = mysqli_stmt_num_rows($stmt))) {
printf("[%03d] Expecting %s/%d, got %s/%d\n", $offset + 3, gettype($expected), $expected, gettype($tmp), $tmp);
}
mysqli_stmt_free_result($stmt);
return true;
}
示例10: getDocID
function getDocID($url)
{
$con = $GLOBALS["con"];
$sql = "SELECT docID FROM documents WHERE URL=?";
$stmt = mysqli_prepare($con, $sql) or die(mysqli_error($con));
mysqli_stmt_bind_param($stmt, 's', $url) or die(mysqli_stmt_error($stmt));
mysqli_stmt_execute($stmt) or die(mysqli_stmt_error($stmt));
mysqli_stmt_store_result($stmt);
if (mysqli_stmt_num_rows($stmt) < 1) {
mysqli_stmt_close($stmt);
$sql = "INSERT INTO documents (URL) VALUES (?)";
$stmt = mysqli_prepare($con, $sql) or die(mysqli_error($con));
mysqli_stmt_bind_param($stmt, 's', $url) or die(mysqli_stmt_error($stmt));
mysqli_stmt_execute($stmt) or die(mysqli_stmt_error($stmt));
mysqli_stmt_bind_result($stmt, $docID);
mysqli_stmt_fetch($stmt);
return getDocID($url);
} else {
mysqli_stmt_bind_result($stmt, $docID);
mysqli_stmt_fetch($stmt);
return $docID;
}
}
示例11: get_key
function get_key($dbh, $config, $key)
{
$data = array();
$result = 0;
$stmt = mysqli_prepare($dbh, "SELECT name,try_interval,last_try FROM " . $config['table_prefix'] . "keys WHERE `key` = ? LIMIT 0,1");
mysqli_stmt_bind_param($stmt, "s", $key);
mysqli_stmt_execute($stmt);
mysqli_stmt_store_result($stmt);
$result = mysqli_stmt_num_rows($stmt);
mysqli_stmt_bind_result($stmt, $name, $try_interval, $last_try);
while (mysqli_stmt_fetch($stmt)) {
$data['name'] = $name;
$data['try_interval'] = $try_interval;
$data['last_try'] = $last_try;
}
mysqli_stmt_close($stmt);
unset($stmt);
if ($result) {
return $data;
} else {
return 0;
}
}
示例12: session_set_cookie_params
//var_dump($_POST);
$lifetime = 86400;
session_set_cookie_params($lifetime, $httponly = true);
if ($link->connect_error) {
die("Connection failed: " . $link->connect_error);
}
//&& $username != $_SESSION['username']
if (!isset($_SESSION['username'])) {
//echo "2";
$username = $_POST['username'];
$password = md5($_POST['password']);
$query = mysqli_prepare($link, "SELECT username, password FROM member WHERE username = ? ");
mysqli_stmt_bind_param($query, 's', $username);
mysqli_stmt_execute($query);
mysqli_stmt_store_result($query);
$rows = mysqli_stmt_num_rows($query);
mysqli_stmt_bind_result($query, $user, $pass);
mysqli_stmt_fetch($query);
if ($rows == 1) {
if ($password == $pass) {
$_SESSION['username'] = $username;
} else {
//password is just wrong or something went wrong with the hashing
echo "wrong hash or pass";
header("location:index.php?invalidcredA");
exit;
}
} else {
//wrong username or multiple entries
header("location:index.php?invalidcredB");
exit;
示例13: logSubject
function logSubject($title)
{
$con = $GLOBALS["con"];
$sql = "SELECT subjectID FROM subjects WHERE Name=?";
//$title
$stmt = mysqli_prepare($con, $sql) or die(mysqli_error($con));
mysqli_stmt_bind_param($stmt, 's', $title) or die(mysqli_stmt_error($stmt));
mysqli_stmt_execute($stmt) or die(mysqli_stmt_error($stmt));
mysqli_stmt_store_result($stmt);
$rows = mysqli_stmt_num_rows($stmt);
mysqli_stmt_close($stmt);
if ($rows < 1) {
$sql = "INSERT INTO subjects (Name) VALUES (?)";
//$title
$stmt = mysqli_prepare($con, $sql) or die(mysqli_error($con));
mysqli_stmt_bind_param($stmt, 's', $title) or die(mysqli_stmt_error($stmt));
mysqli_stmt_execute($stmt) or die(mysqli_stmt_error($stmt));
mysqli_stmt_close($stmt);
}
}
示例14: mysqli_connect
$pass = "t3st3r123";
$db = "test";
$connection = mysqli_connect($host, $user, $pass, $db) or die("ei saa ühendust mootoriga");
mysqli_query($connection, "SET CHARACTER SET UTF8") or die("Ei saanud baasi utf-8-sse - " . mysqli_error($connection));
// php and mysql datetime compatibility http://stackoverflow.com/questions/2215354/php-date-format-when-inserting-into-datetime-in-mysql
$visitTime = date("Y-m-d H:i:s");
$visitorAddress = $_SERVER['REMOTE_ADDR'];
// Insert visitors IP ind current time to DB
$insertVisitQuery = "INSERT INTO rturi_stats (ip, time) VALUES ('" . $visitorAddress . "', '" . $visitTime . "');";
mysqli_query($connection, $insertVisitQuery) or die("Ei saanud kirjet lisatud - " . mysqli_error($connection));
// query how many visits there have been from users IP
$selectNumberOfVisitsQuery = "SELECT * FROM rturi_stats WHERE ip = '" . $visitorAddress . "';";
//row count code copied from http://php.net/manual/en/mysqli-stmt.num-rows.php
if ($stmt = mysqli_prepare($connection, $selectNumberOfVisitsQuery)) {
/* execute query */
mysqli_stmt_execute($stmt);
/* store result */
mysqli_stmt_store_result($stmt);
$numberOfVisits = mysqli_stmt_num_rows($stmt);
/* close statement */
mysqli_stmt_close($stmt);
}
// get the earliest visit datetime from DB
// some help from mysqli tutorial http://codular.com/php-mysqli
$selectEarliestVisitQuery = "SELECT MIN(time) FROM rturi_stats WHERE ip ='88.196.181.145';";
$earliestVisitQueryResult = mysqli_query($connection, $selectEarliestVisitQuery) or die("Kõige varasema külstuse aja päring ebaõnnestus - " . mysqli_error($connection));
$resultRow = $earliestVisitQueryResult->fetch_assoc();
$earliestVisit = $resultRow['MIN(time)'];
echo "Sinu IP aadress on " . $_SERVER['REMOTE_ADDR'] . "<br><br>";
echo "See on sinu " . $numberOfVisits . ". külastus sellel lehel. Esimene külastus oli " . $earliestVisit;
mysqli_close($connection);
示例15: printf
if (($tmp = count($fields_res_meta)) !== $num_fields) {
printf("[015] Expecting int/%d got %s/%s\n", $num_fields, gettype($tmp), $tmp);
}
if ($fields_res_meta != $fields) {
printf("[016] Prepared Statement metadata differs from normal metadata, dumping\n");
var_dump($fields_res_meta);
var_dump($fields);
}
if (function_exists('mysqli_stmt_get_result') && $stmt->prepare('EXPLAIN SELECT t1.*, t2.* FROM test AS t1, test AS t2') && $stmt->execute()) {
if (!($res_stmt = mysqli_stmt_get_result($stmt))) {
printf("[017] Cannot fetch result from PS [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
}
if (($tmp = mysqli_num_rows($res_stmt)) !== $num_rows) {
printf("[018] Expecting int/%d got %s/%s\n", $num_rows, gettype($tmp), $tmp);
}
if (mysqli_stmt_num_rows($stmt) !== 0) {
printf("[019] Expecting int/0 got %s/%s\n", gettype($tmp), $tmp);
}
if (($tmp = mysqli_stmt_field_count($stmt)) !== $num_fields) {
printf("[020] Expecting int/%d got %s/%s\n", $num_fields, gettype($tmp), $tmp);
}
if (($tmp = $res_stmt->field_count) !== $num_fields) {
printf("[021] Expecting int/%d got %s/%s\n", $num_fields, gettype($tmp), $tmp);
}
$fields_stmt = mysqli_fetch_fields($res_stmt);
if (($tmp = count($fields_stmt)) !== $num_fields) {
printf("[022] Expecting int/%d got %s/%s\n", $num_fields, gettype($tmp), $tmp);
}
reset($fields);
foreach ($fields_stmt as $fields_stmt_val) {
list(, $fields_val) = each($fields);