Req #34948 [Tbd]: mysqli_statement and binding array
| From: | uw@php.net | Date: | Thu, 06 Jan 2011 14:12:22 +0000 |
| Subject: | Req #34948 [Tbd]: mysqli_statement and binding array | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-157677@lists.php.net to get a copy of this message | ||
Edit report at http://bugs.php.net/bug.php?id=34948&edit=1
ID: 34948
Updated by: uw@php.net
Reported by: max at webscript dot ru
Summary: mysqli_statement and binding array
Status: To be documented
Type: Feature/Change Request
Package: MySQLi related
Operating System: WinXP Pro
PHP Version: 5CVS-2005-10-21 (snap)
Assigned To: abedford
Block user comment: N
Private report: N
New Comment:
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());
Previous Comments:
------------------------------------------------------------------------
[2011-01-06 15:11:16] uw@php.net
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());
------------------------------------------------------------------------
[2005-10-21 17:26:17] 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
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=34948&edit=1