ID: 42619 User updated by: lmanseau at claurendeau dot qc dot ca Reported By: lmanseau at claurendeau dot qc dot ca -Status: Feedback +Status: Open Bug Type: MySQLi related Operating System: Linux PHP Version: 5.2.4 New Comment:
Here is the SQL definition: CREATE TABLE test1 ( c1 int(4) unsigned zerofill NOT NULL auto_increment, c2 varchar(10) default NULL, c3 double(4,2) default NULL, PRIMARY KEY (c1) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; Code with problem: // Opening connection include ('../mysql/param.inc'); $db = new mysqli($hote, $util, $mpas, $base); if (!$db) { echo "No connection!"; exit(); } echo 'Non Prepared Request<br />'; //WORK WELL $sql = "select * from test1"; $rqp = $db->query($sql); echo 'Rows = '.$rqp->num_rows.'<br />'; echo '<br />Prepared Request<br />'; //DON'T WORK $sql = "select * from ch9books"; $rqp = $db->prepare($sql); $rqp->execute(); echo 'Rows = '.$rqp->num_rows.'<br />'; // Closing connection $db->close(); And the results... Non Prepared Request Rows = 6 Prepared Request Rows = 0 Previous Comments: ------------------------------------------------------------------------ [2007-09-11 08:52:29] uwendel at mysql dot com Please provide a reproducible test case, including SQL definitions and "the other statements" you mention, if they are needed for a minimum test case. Thanks! ------------------------------------------------------------------------ [2007-09-10 20:50:48] lmanseau at claurendeau dot qc dot ca Description: ------------ I try to execute a prepared statement with mysqli. I use PHP 5.2.0 with MySQL 5.0.27 After some tests, prepared statements with MySQL instructions such as (INSERT, DELETE and UPDATE) work very well. The only case problem which I pointed out, it is the instruction SELECT that does not seem to react of good manner - SELECT * FROM table1 dont work - SELECT C1, C2 FROM table1 - dont work I have no error message!!! Reproduce code: --------------- $db = new mysqli($hote, $util, $mpas, $base); if (!$db) { echo "No connection with BD"; exit(); } //WORK WELL echo 'Non prepared statement<br />'; $sql = "select * from ch9books"; $rqp = $db->query($sql); echo 'books = '.$rqp->num_rows.'<br />'; //DONT WORK echo '<br />Prepared statement<br />'; $sql = "select * from ch9books"; $rqp = $db->prepare($sql); $rqp->execute(); echo 'books = '.$rqp->num_rows.'<br />'; $rqp->close(); Expected result: ---------------- Non prepared statement Books = 6 Actual result: -------------- Prepared statement Books = 0 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=42619&edit=1