当前位置: 首页>>代码示例>>PHP>>正文


PHP mysqli_stmt_get_result函数代码示例

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


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


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