• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP mysqli_stmt_get_result函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中mysqli_stmt_get_result函数的典型用法代码示例。如果您正苦于以下问题:PHP mysqli_stmt_get_result函数的具体用法?PHP mysqli_stmt_get_result怎么用?PHP mysqli_stmt_get_result使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: update_vote

function update_vote($image_id)
{
    //get number of votes and update
    global $link;
    /*$result = mysqli_query($link, "SELECT `amount` FROM `votes_amount` WHERE `imageID`=".$image_id.";") or die(mysqli_error($link));
    	$amount = mysqli_fetch_assoc($result);
    	$new_amount = $amount['amount']+1;
    	mysqli_query($link, "UPDATE `votes_amount` SET `amount`=".$new_amount." WHERE `imageID`=".$image_id.";") or die(mysqli_error($link));*/
    $stmt = mysqli_stmt_init($link);
    mysqli_stmt_prepare($stmt, "SELECT `amount` FROM `votes_amount` WHERE `imageID`=?;") or die(mysqli_error($link));
    mysqli_stmt_bind_param($stmt, 'i', $image_id);
    mysqli_stmt_execute($stmt);
    $result = mysqli_stmt_get_result($stmt);
    mysqli_stmt_close($stmt);
    $amount = mysqli_fetch_assoc($result);
    $new_amount = $amount['amount'] + 1;
    $stmt = mysqli_prepare($link, "UPDATE `votes_amount` SET `amount`=" . $new_amount . " WHERE `imageID`=?;") or die(mysqli_error($link));
    mysqli_stmt_bind_param($stmt, 'i', $image_id);
    mysqli_stmt_execute($stmt);
    mysqli_stmt_close($stmt);
    //return ajax data
    if (isset($_SESSION['id']) && !isset($_POST['action']) && !isset($_POST['votePic'])) {
        $data = array('new_amount' => $new_amount, 'imageID' => $image_id);
    } elseif (isset($_POST['action']) && $_POST['action'] == 'anonymous_voting') {
        //get another two images
        $result = mysqli_query($link, "SELECT * FROM `image` ORDER BY RAND() LIMIT 2;") or die(mysqli_error($link));
        $data = array();
        while ($row = mysqli_fetch_assoc($result)) {
            $data[] = $row;
        }
    }
    mysqli_close($link);
    return $data;
}
开发者ID:tinggao,项目名称:woofWarrior,代码行数:34,代码来源:vote.php


示例2: db_vquery

function db_vquery($query, $args) {
	$stmt = db_vce_stmt($query, $args);

	if (!($res = mysqli_stmt_get_result($stmt)))
		fatal_mysqli('mysqli_stmt_get_result');

	if (!mysqli_stmt_close($stmt))
		fatal_mysqli('mysqli_stmt_close');

	return $res;
}
开发者ID:rsnel,项目名称:logdb,代码行数:11,代码来源:db.php


示例3: mysqli_select

function mysqli_select($db, $sql)
{
    $stmt = call_user_func_array('mysqli_interpolate', func_get_args());
    if (!mysqli_stmt_execute($stmt) || false === ($result = mysqli_stmt_get_result($stmt))) {
        throw new mysqli_sql_exception(mysqli_stmt_error($stmt), mysqli_stmt_errno($stmt));
    }
    $rows = mysqli_fetch_all($result, MYSQLI_ASSOC);
    mysqli_free_result($result);
    mysqli_stmt_close($stmt);
    return (array) $rows;
}
开发者ID:s-melnikov,项目名称:booking,代码行数:11,代码来源:functions.php


示例4: mysqli_select

function mysqli_select($db, string $sql, ...$params) : array
{
    $stmt = mysqli_interpolate($db, $sql, ...$params);
    if (!mysqli_stmt_execute($stmt) || false === ($result = mysqli_stmt_get_result($stmt))) {
        throw new mysqli_sql_exception(mysqli_stmt_error($stmt), mysqli_stmt_errno($stmt));
    }
    $rows = mysqli_fetch_all($result, MYSQLI_ASSOC);
    mysqli_free_result($result);
    mysqli_stmt_close($stmt);
    return $rows;
}
开发者ID:noodlehaus,项目名称:mysqli_etc,代码行数:11,代码来源:mysqli_etc.php


示例5: getStatusById

function getStatusById($id)
{
    $connection = dbConnect();
    $options = ['columns' => 'id, status', 'where' => ['id' => $id]];
    $sql = buildSelect('status_atividade', $options);
    $stmt = mysqli_prepare($connection, $sql);
    mysqli_stmt_bind_param($stmt, 'i', $id);
    mysqli_stmt_execute($stmt);
    $resultObject = mysqli_stmt_get_result($stmt);
    $result = mysqli_fetch_all($resultObject, MYSQLI_ASSOC);
    mysqli_stmt_close($stmt);
    dbClose($connection);
    return $result[0];
}
开发者ID:Calcio,项目名称:CursoPHPBasico,代码行数:14,代码来源:queries.php


示例6: getUserById

function getUserById($id)
{
    $connection = dbConnect();
    $options = ['columns' => 'u.id_setor, u.nome, u.email, u.ativo, u.tipo, s.sigla, s.nome as setor', 'join' => [['type' => 'INNER JOIN', 'table' => 'setores s', 'columns' => 's.id = u.id_setor']], 'where' => ['u.id' => $id]];
    $sql = buildSelect('usuarios u', $options);
    $stmt = mysqli_prepare($connection, $sql);
    mysqli_stmt_bind_param($stmt, 'i', $id);
    mysqli_stmt_execute($stmt);
    $resultObject = mysqli_stmt_get_result($stmt);
    $result = mysqli_fetch_all($resultObject, MYSQLI_ASSOC);
    mysqli_stmt_close($stmt);
    dbClose($connection);
    return $result[0];
}
开发者ID:Calcio,项目名称:CursoPHPBasico,代码行数:14,代码来源:queries.php


示例7: getActivitiesById

function getActivitiesById($id)
{
    $connection = dbConnect();
    $options = ['columns' => 'a.id, a.id_demandante, a.id_responsavel, a.id_setor, a.id_status, a.descricao,
        ud.nome as demandante, s.sigla, sa.status, a.titulo, a.data, a.tempo_gasto', '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' => $id]];
    $sql = buildSelect('atividades a', $options);
    $stmt = mysqli_prepare($connection, $sql);
    mysqli_stmt_bind_param($stmt, 'i', $id);
    mysqli_stmt_execute($stmt);
    $resultObject = mysqli_stmt_get_result($stmt);
    $result = mysqli_fetch_all($resultObject, MYSQLI_ASSOC);
    mysqli_stmt_close($stmt);
    dbClose($connection);
    return $result[0];
}
开发者ID:Calcio,项目名称:CursoPHPBasico,代码行数:15,代码来源:queries.php


示例8: comprobar

 public static function comprobar($nick, $clave)
 {
     $con = Conexion::crearConexion();
     $sql = "SELECT * FROM usuario WHERE nick=? AND clave=?";
     $query = mysqli_prepare($con, $sql);
     mysqli_stmt_bind_param($query, "ss", $nick, $clave);
     mysqli_stmt_execute($query);
     $resultado = mysqli_stmt_get_result($query);
     if (mysqli_num_rows($resultado) != 0) {
         Conexion::cerrarConexion($con);
         return true;
     }
     Conexion::cerrarConexion($con);
     return false;
 }
开发者ID:jjbc93,项目名称:EntornoServidor,代码行数:15,代码来源:bd.php


示例9: executeQuery

/**
 * @param string $query
 * @param string $types
 * @param        ...$params
 *
 * @return array|null
 */
function executeQuery($query, $types = null, ...$params)
{
    if ($types !== null) {
        $stmt = mysqli_prepare(getConnection(), $query);
        if (!mysqli_stmt_bind_param($stmt, $types, ...$params)) {
            die('Could not bind query params.');
        }
        if (!mysqli_stmt_execute($stmt)) {
            die('Could not execute mysqli statement.');
        }
        $result = mysqli_stmt_get_result($stmt);
        mysqli_stmt_free_result($stmt);
        return resultQuery($result);
    }
    $result = mysqli_query(getConnection(), $query);
    return resultQuery($result);
}
开发者ID:szybki-ktokolwiek,项目名称:SzybkiAAC,代码行数:24,代码来源:database.php


示例10: db_query

function db_query($sql, $bind = null)
{
    $db = get_var('db');
    $query = false;
    $stmt = mysqli_stmt_init($db);
    $sql = trim($sql);
    if (mysqli_stmt_prepare($stmt, $sql)) {
        if (!empty($bind)) {
            $types = '';
            $values = array();
            foreach ($bind as $key => &$value) {
                $value = stripslashes($value);
                if (is_numeric($value)) {
                    $float = floatval($value);
                    $types .= $float && intval($float) != $float ? 'd' : 'i';
                } else {
                    $types .= 's';
                }
                $values[$key] =& $bind[$key];
            }
            $params = array_merge(array($stmt, $types), $bind);
            call_user_func_array('mysqli_stmt_bind_param', $params);
        }
        if (mysqli_stmt_execute($stmt)) {
            if (preg_match('/^(SELECT|SHOW)/i', $sql)) {
                if (db_native_driver()) {
                    $query = mysqli_stmt_get_result($stmt);
                    mysqli_stmt_close($stmt);
                } else {
                    return $stmt;
                }
            } else {
                $query = TRUE;
                mysqli_stmt_close($stmt);
            }
        } else {
            trigger_error(mysqli_stmt_error($stmt), E_USER_WARNING);
        }
    } else {
        trigger_error(mysqli_error($db), E_USER_WARNING);
    }
    return $query;
}
开发者ID:londomloto,项目名称:immortal,代码行数:43,代码来源:database.php


示例11: initialGameData

function initialGameData($d)
{
    global $mysqli;
    $res = array();
    /* echo $d["playerID0"];
       echo $d["playerID1"];
       echo $d["player0"];
       echo $d["player1"]; */
    $challengeId = intVal($d["challengeId"], 10);
    $playerID0 = intVal($d["fromID"], 10);
    $playerID1 = intVal($d["toID"], 10);
    $color0 = 'white';
    $color1 = 'black';
    $turn = 0;
    $score0 = 0;
    $score1 = 0;
    $sql = "INSERT INTO game(challengeId,playerID0,playerID1,player0,player1,color0,color1,turn,score0,score1) values(?,?,?,?,?,?,?,?,?,?)";
    try {
        if ($stmt = $mysqli->prepare($sql)) {
            //
            $stmt->bind_param("iiissssiii", $challengeId, $playerID0, $playerID1, $d["fromName"], $d["toName"], $color0, $color1, $turn, $score0, $score1);
            $stmt->execute();
            $result = mysqli_stmt_get_result($stmt);
            // echo "<br> result login insert <br/>";
            $gameid = $mysqli->insert_id;
            $stmt->close();
            $mysqli->close();
            $res["success"] = true;
            $res["gameID"] = $gameid;
            $res["responseText"] = $d;
        } else {
            $res["success"] = false;
        }
        return json_encode($res);
    } catch (mysqli_sql_exception $e) {
        throw new MySQLiQueryException($SQL, $e->getMessage(), $e->getCode());
    } catch (Exception $e) {
        echo "ex: " . $e;
        // log_error($e, $sql, null);
        return false;
    }
}
开发者ID:sanafarooqui,项目名称:Othello,代码行数:42,代码来源:gameData.php


示例12: executeQuery

function executeQuery($conn, $sql, array $parameters = []){
	/*For matching the data type for binding*/
	$typesTable = [
		'integer' => 'i',
		'double' => 'd',
		'string' => 's'
	];
	$type = '';
	$stmt = mysqli_stmt_init($conn);
	
	if (!mysqli_stmt_prepare($stmt, $sql)){
		raiseIssue('failed to prepare statement');
		return false;
	}
	/*This bit should only run if any parameters are provided*/
	if (!empty($parameters)){
		foreach ($parameters as $parameter){
			/*Look up the type from the types table */
			$type .= $typesTable[gettype($parameter)];
		}
		array_unshift($parameters, $stmt, $type);
		/*bit hacky because of call_user_func_array, it will not like $parameters by itself so it needs to be "passed in by reference" but calltime pass by reference is deprecated*/
		$preparedParams = [];
		foreach ($parameters as $index => &$label){
			$preparedParams[$index] = &$label;
		}
		
		call_user_func_array('mysqli_stmt_bind_param', $preparedParams);
	}
	mysqli_stmt_execute($stmt);
	
	/*Generating the result set for use. This gives you the column names as keys on each row*/
	$result = mysqli_stmt_get_result($stmt);
	$resultSet = [];
	if(!$result){ return $resultSet; /*skips the result fetching if no results obtained*/}
	while ($row = mysqli_fetch_assoc($result)){
		$resultSet[] = $row;
	}
	mysqli_stmt_close($stmt);
	
	return $resultSet;
}
开发者ID:arielrossanigo,项目名称:trabajo_final,代码行数:42,代码来源:gb4etgDE.PHP


示例13: mysqli_real_escape_string

<?php

require 'connectdb.php';
$login_username = mysqli_real_escape_string($dbcon, $_POST['username']);
$login_password = mysqli_real_escape_string($dbcon, $_POST['password']);
$salt = 'tikde78uj4ujuhlaoikiksakeidkd';
$hash_login_password = hash_hmac('sha256', $login_password, $salt);
$sql = "SELECT * FROM tb_login WHERE login_username=? AND login_password=?";
$stmt = mysqli_prepare($dbcon, $sql);
mysqli_stmt_bind_param($stmt, "ss", $login_username, $hash_login_password);
mysqli_execute($stmt);
$result_user = mysqli_stmt_get_result($stmt);
if ($result_user->num_rows == 1) {
    session_start();
    $row_user = mysqli_fetch_array($result_user, MYSQLI_ASSOC);
    $_SESSION['login_id'] = $row_user['login_id'];
    header("Location: ../index.php");
} else {
    echo "ผู้ใช้หรือรหัสผ่านไม่ถูกต้อง";
}
开发者ID:HomeRuk,项目名称:PHP_CRUD,代码行数:20,代码来源:login.php


示例14: printf

    printf("[019] Expecting object/mysqli_result got %s/%s, [%d] %s\n", gettype($res), $res, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
}
$id = $label = null;
if (!mysqli_stmt_bind_result($stmt, $id, $label)) {
    printf("[020] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
}
$row = mysqli_fetch_assoc($res);
if (NULL !== $id || NULL !== $label) {
    printf("[021] Bound variables should not have been set\n");
}
mysqli_free_result($res);
mysqli_stmt_close($stmt);
if (!($stmt = mysqli_stmt_init($link)) || !mysqli_stmt_prepare($stmt, "SELECT id, label FROM test ORDER BY id ASC LIMIT 2") || !mysqli_stmt_execute($stmt)) {
    printf("[022] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
}
if (!is_object($res = mysqli_stmt_get_result($stmt)) || 'mysqli_result' != get_class($res)) {
    printf("[023] Expecting object/mysqli_result got %s/%s, [%d] %s\n", gettype($res), $res, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
}
if (!in_array($res->type, array(MYSQLI_STORE_RESULT, MYSQLI_USE_RESULT))) {
    printf("[024] Unknown result set type %s\n", $res->type);
}
if ($res->type !== MYSQLI_STORE_RESULT) {
    printf("[025] Expecting int/%d got %s/%s", MYSQLI_STORE_RESULT, gettype($res->type), $res->type);
}
mysqli_free_result($res);
mysqli_stmt_close($stmt);
mysqli_close($link);
if (NULL !== ($res = mysqli_stmt_get_result($stmt))) {
    printf("[022] Expecting NULL got %s/%s\n", gettype($res), $res);
}
print "done!";
开发者ID:gleamingthecube,项目名称:php,代码行数:31,代码来源:ext_mysqli_tests_mysqli_stmt_get_result2.php


示例15: func_mysqli_stmt_get_result_geom

function func_mysqli_stmt_get_result_geom($link, $engine, $sql_type, $bind_value, $offset)
{
    if (!mysqli_query($link, "DROP TABLE IF EXISTS test_mysqli_stmt_get_result_geom_table_1")) {
        printf("[%04d] [%d] %s\n", $offset, mysqli_errno($link), mysqli_error($link));
        return false;
    }
    if (!mysqli_query($link, sprintf("CREATE TABLE test_mysqli_stmt_get_result_geom_table_1(id INT, label %s, PRIMARY KEY(id)) ENGINE = %s", $sql_type, $engine))) {
        // don't bail - column type might not be supported by the server, ignore this
        return false;
    }
    for ($id = 1; $id < 4; $id++) {
        $sql = sprintf("INSERT INTO test_mysqli_stmt_get_result_geom_table_1(id, label) VALUES (%d, %s)", $id, $bind_value);
        if (!mysqli_query($link, $sql)) {
            printf("[%04d] [%d] %s\n", $offset + 2 + $id, mysqli_errno($link), mysqli_error($link));
        }
    }
    if (!($stmt = mysqli_stmt_init($link))) {
        printf("[%04d] [%d] %s\n", $offset + 6, mysqli_errno($link), mysqli_error($link));
        return false;
    }
    if (!mysqli_stmt_prepare($stmt, "SELECT id, label FROM test_mysqli_stmt_get_result_geom_table_1")) {
        printf("[%04d] [%d] %s\n", $offset + 7, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
        mysqli_stmt_close($stmt);
        return false;
    }
    if (!mysqli_stmt_execute($stmt)) {
        printf("[%04d] [%d] %s\n", $offset + 8, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
        mysqli_stmt_close($stmt);
        return false;
    }
    if (!($res = mysqli_stmt_get_result($stmt))) {
        printf("[%04d] [%d] %s\n", $offset + 9, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
        mysqli_stmt_close($stmt);
        return false;
    }
    $result = mysqli_stmt_result_metadata($stmt);
    $fields = mysqli_fetch_fields($result);
    if ($fields[1]->type != MYSQLI_TYPE_GEOMETRY) {
        printf("[%04d] [%d] %s wrong type %d\n", $offset + 10, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt), $fields[1]->type);
    }
    $num = 0;
    while ($row = mysqli_fetch_assoc($res)) {
        $bind_res =& $row['label'];
        if (!($stmt2 = mysqli_stmt_init($link))) {
            printf("[%04d] [%d] %s\n", $offset + 11, mysqli_errno($link), mysqli_error($link));
            return false;
        }
        if (!mysqli_stmt_prepare($stmt2, "INSERT INTO test_mysqli_stmt_get_result_geom_table_1(id, label) VALUES (?, ?)")) {
            printf("[%04d] [%d] %s\n", $offset + 12, mysqli_stmt_errno($stmt2), mysqli_stmt_error($stmt2));
            return false;
        }
        $id = $row['id'] + 10;
        if (!mysqli_stmt_bind_param($stmt2, "is", $id, $bind_res)) {
            printf("[%04d] [%d] %s\n", $offset + 13, mysqli_stmt_errno($stmt2), mysqli_stmt_error($stmt2));
            return false;
        }
        if (!mysqli_stmt_execute($stmt2)) {
            printf("[%04d] [%d] %s\n", $offset + 14, mysqli_stmt_errno($stmt2), mysqli_stmt_error($stmt2));
            return false;
        }
        mysqli_stmt_close($stmt2);
        if (!($res_normal = mysqli_query($link, sprintf("SELECT id, label FROM test_mysqli_stmt_get_result_geom_table_1 WHERE id = %d", $row['id'] + 10)))) {
            printf("[%04d] [%d] %s\n", $offset + 15, mysqli_errno($link), mysqli_error($link));
            return false;
        }
        if (!($row_normal = mysqli_fetch_assoc($res_normal))) {
            printf("[%04d] [%d] %s\n", $offset + 16, mysqli_errno($link), mysqli_error($link));
            return false;
        }
        if ($row_normal['label'] != $bind_res) {
            printf("[%04d] PS and non-PS return different data.\n", $offset + 17);
            return false;
        }
        mysqli_free_result($res_normal);
        $num++;
    }
    if ($num != 3) {
        printf("[%04d] [%d] %s, expecting 3 results, got only %d results\n", $offset + 18, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt), $num);
        mysqli_free_result($res);
        mysqli_stmt_close($stmt);
        return false;
    }
    mysqli_free_result($res);
    mysqli_stmt_close($stmt);
    return true;
}
开发者ID:badlamer,项目名称:hhvm,代码行数:86,代码来源:mysqli_stmt_get_result_geom.php


示例16: saveChallengeStatusGame

function saveChallengeStatusGame($d)
{
    $res = array();
    $challengeID = intVal($d["challengeID"], 10);
    // $toID = intVal($d["toID"],10);
    $accepted = filter_var($d["accepted"], FILTER_VALIDATE_BOOLEAN);
    global $mysqli;
    $sql = "Update challenge set accepted=? where challengeID=?";
    try {
        if ($stmt = $mysqli->prepare($sql)) {
            $stmt->bind_param("ii", $accepted, $challengeID);
            $stmt->execute();
            $result = mysqli_stmt_get_result($stmt);
            $stmt->close();
            $mysqli->close();
            if ($accepted) {
                $res["success"] = true;
                $res["accepted"] = true;
                $res["responseText"] = $d;
            }
        }
        return json_encode($res);
    } catch (mysqli_sql_exception $e) {
        throw new MySQLiQueryException($SQL, $e->getMessage(), $e->getCode());
    } catch (Exception $e) {
        echo log_error($e, $sql, null);
        //return false;
        echo 'fail';
    }
}
开发者ID:sanafarooqui,项目名称:Othello,代码行数:30,代码来源:chatData.php


示例17: db_read

/**
 * @param $sql
 * @param $paras
 * @return array|string
 */
function db_read($sql, $paras)
{
    if (dbconfig_r::Provider == "mysqli") {
        //mysqli的情况
        if (extension_loaded("mysqli")) {
            $con = mysqli_connect(dbconfig_r::DataSource, dbconfig_r::UserID, dbconfig_r::Password, dbconfig_r::InitialCatalog, dbconfig_r::Port);
            if ($con != false) {
                mysqli_real_query($con, "SET NAMES UTF8");
                if ($paras == null) {
                    $table = mysqli_query($con, $sql);
                    $data = array();
                    if ($table != false) {
                        while ($row = mysqli_fetch_object($table)) {
                            array_push($data, $row);
                        }
                    } else {
                        $data = dberror::SQL_EXCEPTION;
                    }
                } else {
                    $mt = $con->stmt_init();
                    $mt->prepare($sql);
                    $types = "";
                    $vals = "";
                    $valsl = "";
                    $i = 0;
                    foreach ($paras as $para) {
                        if ($vals != "") {
                            $vals .= ",";
                        }
                        $i += 1;
                        $val = $para->value;
                        $valsl .= "\$" . "vals" . $i . "='" . $val . "';";
                        $vals .= "\$" . "vals" . $i;
                        $types .= $para->type;
                    }
                    $cmd = $valsl . "\$" . "tmp=mysqli_stmt_bind_param(\$" . "mt,'{$types}'," . $vals . ");";
                    eval($cmd);
                    unset($para);
                    mysqli_stmt_execute($mt);
                    $rel = mysqli_stmt_get_result($mt);
                    $data = array();
                    if ($rel != false) {
                        while ($row = mysqli_fetch_array($rel)) {
                            array_push($data, $row);
                        }
                    } else {
                        return dberror::SQL_EXCEPTION;
                    }
                }
                mysqli_close($con);
                return $data;
            } else {
                return dberror::CONNECT_EXCEPTION;
            }
        } else {
            return dberror::NO_MYSQLI_EXCEPTION;
        }
    } else {
        //mysql的情况
        if (extension_loaded("mysql")) {
            $con = mysql_connect(dbconfig_r::DataSource, dbconfig_r::UserID, dbconfig_r::Password, dbconfig_r::InitialCatalog, dbconfig_r::Port);
            if ($con != false) {
                mysql_query($con, "SET NAMES UTF8");
                if ($paras == null) {
                    $table = mysql_query($con, $sql);
                    $data = array();
                    if ($table != false) {
                        while ($row = mysql_fetch_object($table)) {
                            array_push($data, $row);
                        }
                    } else {
                        $data = dberror::SQL_EXCEPTION;
                    }
                } else {
                    $data = dberror::MYSQL_NO_PREPARE_EXCEPTION;
                }
                mysql_close($con);
                return $data;
            } else {
                return dberror::CONNECT_EXCEPTION;
            }
        } else {
            return dberror::NO_MYSQL_EXCEPTION;
        }
    }
}
开发者ID:Takeya-Yuki-Studio,项目名称:Yuki-Auth-Login,代码行数:91,代码来源:dbconnect.php


示例18: testStatement

function testStatement($offset, $link, $sql, $expected_lib, $expected_mysqlnd, $check_mysqlnd, $compare)
{
    if (!($stmt = mysqli_stmt_init($link))) {
        printf("[%04d - %s] [%d] %s\n", $offset, $sql, mysqli_errno($link), mysqli_error($link));
        return false;
    }
    if (!@mysqli_stmt_prepare($stmt, $sql)) {
        /* Not all server versions will support all statements */
        /* Failing to prepare is OK */
        return true;
    }
    if (empty($expected_lib) && false !== $res) {
        printf("[%04d - %s] No metadata expected\n", $offset + 1, $sql);
        return false;
    } else {
        if (!empty($expected_lib) && false == $res) {
            printf("[%04d - %s] Metadata expected\n", $offset + 2, $sql);
            return false;
        }
    }
    if (!empty($expected_lib)) {
        if (!is_object($res)) {
            printf("[%04d - %s] [%d] %s\n", $offset + 3, $sql, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
            return false;
        }
        if (get_class($res) != 'mysqli_result') {
            printf("[%04d - %s] Expecting object/mysqli_result got object/%s\n", $offset + 4, $sql, get_class($res));
            return false;
        }
        $meta = array('num_fields' => mysqli_num_fields($res), 'fetch_field' => mysqli_fetch_field($res), 'fetch_field_direct0' => mysqli_fetch_field_direct($res, 0), 'fetch_field_direct1' => @mysqli_fetch_field_direct($res, 1), 'fetch_fields' => count(mysqli_fetch_fields($res)), 'field_count' => $res->field_count, 'field_seek-1' => @mysqli_field_seek($res, -1), 'field_seek0' => mysqli_field_seek($res, 0), 'field_tell' => mysqli_field_tell($res));
        if (is_object($meta['fetch_field'])) {
            $meta['fetch_field']->charsetnr = 'ignore';
            $meta['fetch_field']->flags = 'ignore';
        }
        if (is_object($meta['fetch_field_direct0'])) {
            $meta['fetch_field_direct0']->charsetnr = 'ignore';
            $meta['fetch_field_direct0']->flags = 'ignore';
        }
        if (is_object($meta['fetch_field_direct1'])) {
            $meta['fetch_field_direct1']->charsetnr = 'ignore';
            $meta['fetch_field_direct1']->flags = 'ignore';
        }
        mysqli_free_result($res);
        if ($meta != $expected_lib) {
            printf("[%04d - %s] Metadata differs from expected values\n", $offset + 5, $sql);
            var_dump($meta);
            var_dump($expected_lib);
            return false;
        }
    }
    if (function_exists('mysqli_stmt_get_result')) {
        /* mysqlnd only */
        if (!mysqli_stmt_execute($stmt)) {
            printf("[%04d - %s] [%d] %s\n", $offset + 6, $sql, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
            return false;
        }
        $res = mysqli_stmt_get_result($stmt);
        if (false === $res && !empty($expected_mysqlnd)) {
            printf("[%04d - %s] Expecting resultset [%d] %s\n", $offset + 7, $sql, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
            return false;
        } else {
            if (empty($expected_mysqlnd) && false !== $res) {
                printf("[%04d - %s] Unexpected resultset [%d] %s\n", $offset + 8, $sql, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
                return false;
            }
        }
        if (!is_object($res)) {
            printf("[%04d - %s] [%d] %s\n", $offset + 9, $sql, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
            return false;
        }
        if ('mysqli_result' != get_class($res)) {
            printf("[%04d - %s] Expecting object/mysqli_result got object/%s\n", $offset + 10, $sql, get_class($res));
            return false;
        }
        $meta_res = array('num_fields' => mysqli_num_fields($res), 'fetch_field' => mysqli_fetch_field($res), 'fetch_field_direct0' => mysqli_fetch_field_direct($res, 0), 'fetch_field_direct1' => @mysqli_fetch_field_direct($res, 1), 'fetch_fields' => count(mysqli_fetch_fields($res)), 'field_count' => mysqli_field_count($link), 'field_seek-1' => @mysqli_field_seek($res, -1), 'field_seek0' => mysqli_field_seek($res, 0), 'field_tell' => mysqli_field_tell($res));
        if (is_object($meta_res['fetch_field'])) {
            $meta_res['fetch_field']->charsetnr = 'ignore';
            $meta_res['fetch_field']->flags = 'ignore';
        }
        if (is_object($meta_res['fetch_field_direct0'])) {
            $meta_res['fetch_field_direct0']->charsetnr = 'ignore';
            $meta_res['fetch_field_direct0']->flags = 'ignore';
        }
        if (is_object($meta_res['fetch_field_direct1'])) {
            $meta_res['fetch_field_direct1']->charsetnr = 'ignore';
            $meta_res['fetch_field_direct1']->flags = 'ignore';
        }
        mysqli_free_result($res);
        if ($check_mysqlnd && $meta_res != $expected_mysqlnd) {
            printf("[%04d - %s] Metadata differs from expected\n", $offset + 11, $sql);
            var_dump($meta_res);
            var_dump($expected_mysqlnd);
        } else {
            if ($meta_res['field_count'] < 1) {
                printf("[%04d - %s] Metadata seems wrong, no fields?\n", $offset + 12, $sql);
                var_dump($meta_res);
                var_dump(mysqli_fetch_assoc($res));
            }
        }
        if ($compare && $meta_res != $meta) {
//.........这里部分代码省略.........
开发者ID:badlamer,项目名称:hhvm,代码行数:101,代码来源:mysqli_stmt_result_metadata_sqltests.php


示例19: error_reporting

<?php

include 'db_connect.php';
error_reporting(-1);
ini_set('display_errors', 'On');
//---------------------------------------------------------------------------------INPUTS---------------------------------------------------------------------------------
$email = strtoupper($_REQUEST["username"]);
$email = $link->real_escape_string($email);
//------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
$user = array();
// array that will be returned as JSON string
//Query to check if user exist
$query = "SELECT * FROM users WHERE email = ?";
if ($stmt = $link->prepare($query)) {
    mysqli_stmt_bind_param($stmt, "s", $email);
    mysqli_stmt_execute($stmt);
    $user_results = mysqli_stmt_get_result($stmt);
    if ($user_results_rows = mysqli_fetch_assoc($user_results)) {
        $user["password"] = $user_results_rows["password"];
        $user["firstName"] = $user_results_rows["firstName"];
        $user["lastName"] = $user_results_rows["lastName"];
    }
}
echo json_encode($user);
mysqli_close($link);
开发者ID:CagedAnimal,项目名称:i2iRebuild,代码行数:25,代码来源:FetchUserData.php


示例20: suicide

    $response["text"] = $messages;
    suicide($response, "success");
}
// let's convert the mysql result to an associative array
foreach ($result as $key => $value) {
    // for each row we'll take the poster ID
    $posterid = $value["userid"];
    // then will connect to the users table asking for the name and the thumbnail
    $stmt = mysqli_prepare($db, "SELECT name, img FROM users WHERE id=?");
    if (!mysqli_stmt_bind_param($stmt, 'i', $posterid)) {
        suicide("Error: " . mysqli_error($db), "error");
    }
    if (!mysqli_stmt_execute($stmt)) {
        suicide("Error: " . mysqli_error($db), "error");
    }
    if (!($userresult = mysqli_stmt_get_result($stmt))) {
        suicide("Error: " . mysqli_error($db), "error");
    }
    if (!mysqli_stmt_close($stmt)) {
        suicide("Error: " . mysqli_error($db), "error");
    }
    // so now we have a result, this result contains only one row..
    // so let's access that row by a foreach loop
    // and take the thumbnail and username.. and add it to the result from the messages table
    foreach ($userresult as $rownum => $rowval) {
        $value["thumb"] = $rowval["img"];
        $value["name"] = $rowval["name"];
    }
    // now let's escape any HTML elements that the content might have to prevent users from using
    // the HTML elements to make thier text bold or embeding web pages or anything like that
    $value["content"] = htmlspecialchars($value["content"], ENT_HTML5, 'UTF-8', false);
开发者ID:studywithyou,项目名称:ajaxchat,代码行数:31,代码来源:room.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP mysqli_stmt_init函数代码示例发布时间:2022-05-15
下一篇:
PHP mysqli_stmt_free_result函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap