| Bug #45289 | Cannot use prepared statements and fetch_row together | ||||
|---|---|---|---|---|---|
| Submitted: | 17 Jun 2008 2:33am UTC | Modified: | 21 Sep 2009 3:16pm UTC | ||
| From: | mike dot benza at rice dot edu | Assigned to: | |||
| Status: | Bogus | Category: | MySQLi related | ||
| Version: | 5.2.4 | OS: | * | ||
| Votes: | 7 | Avg. Score: | 4.7 ± 0.5 | Reproduced: | 7 of 7 (100.0%) |
| Same Version: | 0 (0.0%) | Same OS: | 2 (28.6%) | ||
[17 Jun 2008 2:33am UTC] mike dot benza at rice dot edu
[11 Jul 2008 8:54am UTC] omolano at PLEASENOSPAMinicia dot es
I've also had this problem. In my case I was trying to use PDO::FETCH_ASSOC on a prepared statement and the database was SQLite 3 based. I also got null values, like the above poster, not garbage.
[14 Jul 2008 9:05pm UTC] jani@php.net
Please try using this CVS snapshot: http://snaps.php.net/php5.2-latest.tar.gz For Windows (zip): http://snaps.php.net/win32/php5.2-win32-latest.zip For Windows (installer): http://snaps.php.net/win32/php5.2-win32-installer-latest.msi
[22 Jul 2008 1:00am UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is being suspended automatically. If you are able to provide the information that was originally requested, please do so and change the status of the bug back to "Open".
[15 May 2009 1:39pm UTC] jochen dot wiedmann at gmail dot com
I have the same problem with PHP 5.2.6, as delivered with Fedora 10 Linux.
[15 May 2009 7:55pm UTC] jochen dot wiedmann at gmail dot com
I have checked the latest snapshot (php5.2-200905151830), whether the
problem still persists by using the script below. (Should be easy to
derive a .phpt file from it.)
<?php
$mysqli = mysqli_init();
$mysqli->real_connect("localhost", "root", null, 'test');
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
$mysqli->query("DROP TABLE IF EXISTS prep_and_fetch_row")
or die($mysqli->error);
$mysqli->query("CREATE TABLE prep_and_fetch_row(id BIGINT NOT NULL
PRIMARY KEY, name VARCHAR(64) NOT NULL)")
or die($mysqli->error);
$mysqli->query("INSERT INTO prep_and_fetch_row (id, name) VALUES (1,
'abc')")
or die($mysqli->error);
$stmt = $mysqli->prepare("SELECT * FROM prep_and_fetch_row WHERE
id=?")
or die($mysqli->error);
$id = "1";
$stmt->bind_param("i", $id) or die($mysqli->error);
$stmt->execute() or die($mysqli->error);
$result = $mysqli->use_result() or die($mysqli->error);
while ($row = $result->fetch_row()) {
print "----- result row -----------\n";
print_r($row);
}
print "----- no more results -----------\n";
$mysqli->query("DROP TABLE prep_and_fetch_row") or
die($mysqli->error);
$mysqli->close();
?>
Expected output: Something like
----- result row -----------
Array
(
[0] => int(1)
[1] => string(3) "abc"
)
----- no more results -----------
Actual output:
----- result row -----------
Array
(
[0] =>
[1] =>
)
----- no more results -----------
I'd consider this to be a clear bug.
[28 May 2009 6:16pm UTC] uw@php.net
I think its bogus. Wrong use of the API. The critical part here is that you get a result set at all...
[21 Sep 2009 3:16pm UTC] uw@php.net
In this case mysql_store_result() should not return a result set. Closing because it is a matter of the MySQL Client Library and not PHP. See also http://bugs.mysql.com/bug.php?id=47485 .
