php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #34948 mysqli_statement and binding array
Submitted: 2005-10-21 17:26 UTC Modified: 2011-03-23 16:32 UTC
Votes:2
Avg. Score:5.0 ± 0.0
Reproduced:2 of 2 (100.0%)
Same Version:1 (50.0%)
Same OS:0 (0.0%)
From: max at webscript dot ru Assigned: abedford (profile)
Status: Closed Package: MySQLi related
PHP Version: 5CVS-2005-10-21 (snap) OS: WinXP Pro
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: max at webscript dot ru
New email:
PHP Version: OS:

 

 [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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-01-01 23:47 UTC] jani@php.net
-Summary: [MYSQLI] mysqli_statement and binding array +Summary: mysqli_statement and binding array -Package: Feature/Change Request +Package: MySQLi related
 [2011-01-06 15:11 UTC] uw@php.net
-Status: Open +Status: To be documented -Assigned To: +Assigned To: abedford
 [2011-01-06 15:11 UTC] 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());
 [2011-01-06 15:12 UTC] uw@php.net
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());
 [2011-03-23 16:29 UTC] abedford@php.net
Automatic comment from SVN on behalf of abedford
Revision: http://svn.php.net/viewvc/?view=revision&revision=309605
Log: Add docs for mysqli_stmt_get_result. Fixes #34948
 [2011-03-23 16:32 UTC] abedford@php.net
-Status: To be documented +Status: Closed
 [2011-03-23 16:32 UTC] abedford@php.net
Added docs for mysqli_stmt_get_result.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu May 02 18:01:32 2024 UTC