|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2005-10-21 17:26 UTC] max at webscript dot ru
Description:
------------
Binding array for results of prepared statments in mysqli.
Reproduce code:
---------------
now if I want to work with result of prepared statements I should use mysqli_bind_result().
And if i use table with many columns i need to write variable for all this columns :
-----
$stmt = mysqli_prepare($link, "SELECT * FROM test_bind_fetch");
mysqli_bind_result($stmt, $c1, $c2, $c3, $c4, $c5, $c6, $c7);
-----
I think it would be better to make function
mysqli_bind_result_array($stmt, $array, $array_type);
Where $stmt - mysqli_statement
$array - array, where we will save data from query
$array_type = MYSQLI_ASSOC || MYSQLI_NUM || MYSQLI_BOTH
I know, that this can be emulated with mysqli_fetch_fileds() + call_user_func_array() but it's not comfortable :-)
Expected result:
----------------
$stmt = mysqli_prepare($link, "SELECT * FROM test_bind_fetch");
mysqli_bind_result_array($stmt, $row, MYSQLI_ASSOC);
mysqli_fetch($stmt);
...
now $row will contain data from one record of our query
Actual result:
--------------
no result yet
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Dec 01 03:00:01 2025 UTC |
Functionality exists as of PHP 5.3.x (x = 0, probably). Not properly documented. MySQLiStatement::get_result() needs to be documented. $m = new mysqli("localhost", "root", "root"); $s = $m->prepare("SELECT ? FROM DUAL"); $hello = 'hello'; $s->bind_param("s", $hello); $s->execute(); $r = $s->get_result(); var_dump($r->fetch_all());Functionality exists. Probably since 5.3.0. MySQLiStatement::get_result() needs to be documented as it seems. $m = new mysqli("localhost", "root", "root"); $s = $m->prepare("SELECT ? FROM DUAL"); $hello = 'hello'; $s->bind_param("s", $hello); $s->execute(); $r = $s->get_result(); var_dump($r->fetch_all());