php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #31555 'select query -> prepare -> store_result' doesn't return the data
Submitted: 2005-01-14 16:50 UTC Modified: 2005-02-04 14:59 UTC
From: mauroi at digbang dot com Assigned:
Status: Not a bug Package: MySQLi related
PHP Version: 5.0.3 OS:
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: mauroi at digbang dot com
New email:
PHP Version: OS:

 

 [2005-01-14 16:50 UTC] mauroi at digbang dot com
Description:
------------
I'm trying to bind the parameters for a SELECT query using the mysqli extension. So, I prepare the query, bind the variables, execute, an obtain the result. But in the obtained result I can fetch row (the correct quantity), I can fetch the fields, but it doesn't return any data....

Reproduce code:
---------------
$handle = new mysqli('x.x.x.x', 'x', 'x', 'x');
$stmt = $handle->prepare('SELECT User.User FROM User WHERE User.User = ? AND User.Password = ?');
$user = 'plenque';
$pass = 'plenque';
$stmt->bind_param('ss', $user, $pass);
$stmt->execute();
$result = $handle->store_result();
echo '<pre>';
var_dump($result->fetch_fields());
var_dump($result->fetch_assoc());
echo '<pre>';
$result->close();
$stmt->close();
$handle->close();

Expected result:
----------------
array(1) {
  [0]=>
  object(stdClass)#4 (9) {
    ["name"]=>
    string(7) "User"
    ["orgname"]=>
    string(7) "User"
    ["table"]=>
    string(7) "User"
    ["orgtable"]=>
    string(7) "User"
    ["def"]=>
    string(0) ""
    ["max_length"]=>
    int(0)
    ["flags"]=>
    int(1)
    ["type"]=>
    int(253)
    ["decimals"]=>
    int(0)
  }
}
array(1) {
  ["User"]=>
  string(0) "plenque"
}

Actual result:
--------------
array(1) {
  [0]=>
  object(stdClass)#4 (9) {
    ["name"]=>
    string(7) "User"
    ["orgname"]=>
    string(7) "User"
    ["table"]=>
    string(7) "User"
    ["orgtable"]=>
    string(7) "User"
    ["def"]=>
    string(0) ""
    ["max_length"]=>
    int(0)
    ["flags"]=>
    int(1)
    ["type"]=>
    int(253)
    ["decimals"]=>
    int(0)
  }
}
array(1) {
  ["User"]=>
  string(0) ""   <----- ?????????
}

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-01-14 16:57 UTC] mauroi at digbang dot com
Maybe there's now way of binding parameters and using the result object (then, you can only fetch data from the statement with a more limited API). But in that case mysqli::store_result shouldn't return a result object. Anyway, I think that using a result object (just like oci8 extension does) is a good practice.
 [2005-01-26 17:12 UTC] mauroi at digbang dot com
does the "open" status mean that the suggested modification will be adopted? because i had no feedback :S
 [2005-02-04 14:59 UTC] georg@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions. 

Thank you for your interest in PHP.

Please study the documentation on 
http://www.php.net/mysqli or read the article on 
http://www.zend.com/php5/articles/php5-mysqli.php 
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Fri Sep 17 13:03:37 2021 UTC