php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #34828 new mysqli_result($mysql); doesn't return expected instance
Submitted: 2005-10-11 15:02 UTC Modified: 2005-10-14 16:40 UTC
From: navin@php.net Assigned:
Status: Not a bug Package: MySQLi related
PHP Version: 5.0.5 OS: Windows XP Pro SP2
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
48 - 7 = ?
Subscribe to this entry?

 
 [2005-10-11 15:02 UTC] navin@php.net
Description:
------------
new mysqli_result($mysql); doesn't return expected instance

Reproduce code:
---------------
$mysql = new mysqli('localhost', 'root', '', 'test');

$mysql->query('SELECT * FROM `test`');

$result = new mysqli_result($mysql);

$row = $result->fetch_row();

$result->close();
$mysql->close();

var_dump($row);

Expected result:
----------------
array

Actual result:
--------------
NULL

+ Warning messages:

Warning: Couldn't fetch mysqli_result in test.php on line 4
Warning: Couldn't fetch mysqli_result in test.php on line 6

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-10-11 15:07 UTC] derick@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5-STABLE-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5.0-win32-latest.zip
 [2005-10-11 15:10 UTC] navin@php.net
This works:

$mysql = new mysqli('localhost', 'root', '', 'test');
$mysql->query("SELECT 'test'");
$result = new mysqli_result($mysql);
$row = $result->fetch_row();

And this doesn't:

$mysql = new mysqli('localhost', 'root', '', 'test');
$result = $mysql->query("SELECT 'test'");
$row = $result->fetch_row();
 [2005-10-11 15:12 UTC] derick@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5-STABLE-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5.0-win32-latest.zip
 [2005-10-11 15:29 UTC] tony2001@php.net
Use $mysql->real_query() if you want to create mysqli_result instance yourself.
No bug here, that's how it works.
 [2005-10-11 15:54 UTC] navin@php.net
Oups, a mistake in my previous comment. I ment:

This works:

$mysql = new mysqli('localhost', 'root', '', 'test');
$result = $mysql->query("SELECT 'test'");
$row = $result->fetch_row();

And this doesn't:

$mysql = new mysqli('localhost', 'root', '', 'test');
$mysql->query("SELECT 'test'");
$result = new mysqli_result($mysql);
$row = $result->fetch_row();

---------------

$mysql->real_query('...'); is not relevant to this problem.
 [2005-10-14 16:31 UTC] navin@php.net
Tested the latest 5.0.6-dev from snaps.php.net

$mysql = new mysqli($host, $user, $passwd);
$mysql->real_query("SELECT 'foo' FROM DUAL");
$myresult = new mysqli_result($mysql);
$row = $myresult->fetch_row();
$myresult->close();
$mysql->close();

And it fails the test. (Couldn't fetch mysqli_result...)
 [2005-10-14 16:40 UTC] navin@php.net
With PHP-5.1.0RC1 works ok though.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 18 16:01:29 2024 UTC