PEAR DB, mysqli, and prepared statements problem

From: Date: Fri, 16 Apr 2004 02:35:44 +0000
Subject: PEAR DB, mysqli, and prepared statements problem
Groups: php.pear.general 
Request: Send a blank email to pear-general+get-11899@lists.php.net to get a copy of this message
I'm attempting to use PHP5 RC1 and the PEAR DB class with the mysqli driver to implement prepared statements that are passed to a MySQL 4.1.1 installation. The problem is that strings passed in prepared statements do not appear in the database (i.e. fields are NULL), although integer values do. For example, suppose I have a simple table like: [ID] int (primary key, auto increment) [Age] int [Name] varchar Then using PEAR::DB: PHP: $stmt = $db->prepare("INSERT INTO Tablename VALUES('', ?, ?)"); $db->execute($stmt, array(1, 'Michael')); This will not work correctly. When I view the database, the Age field will have been filled in with a 1, but the varchar field Name will be blank. Everything works fine if I define the values in the actual query string itself and use $db->query(). On the other hand, creating a handle $mysqli = new mysqli() and using prepared statements works fine. PHP: $stmt = $mysqli->prepare("INSERT INTO Tablename VALUES('', ?, ?)"); $stmt->bind_param('is', $age, $name); $age = 1; $name = 'Michael'; $stmt->execute(); No problems at all there. I notice raw mysqli has me specify the datatype for each field in the bind_param() call. I did not see any similar requirement with PEAR::DB. Has anyone else experimented with this yet? Thanks for any help. Abiel Reinhart abielr@myrealbox.com --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.580 / Virus Database: 367 - Release Date: 2/6/2004

« previous php.pear.general (#11899) next »