Question 1:

When using PEAR DB, are you supposed to be able to use a prepared statement
multiple times?  I would suppose yes, but when I execute the code below,
the second use of the prepared statement results in an error:

$stmt = $conn->prepare ("INSERT INTO abc (i, c) VALUES (?, ?)");
if (DB::isError ($stmt))
     die ("prepare() failed: " . $stmt->getMessage () . "\n");

$result = $conn->execute ($stmt, array (4, "d"));
if (DB::isError ($result))
     die ("execute() failed: " . $result->getMessage () . "\n");

$result = $conn->execute ($stmt, array (5, "e"));
if (DB::isError ($result))
     die ("execute() 2 failed: " . $result->getMessage () . "\n");

The error message from the script is:

execute() 2 failed: DB Error: syntax error

I'm using MySQL. The queries that show up in the MySQL log file are:

23304 Query       INSERT INTO abc (i, c) VALUES ('4', 'd')
23304 Query       Object

Looks to me like $stmt is being munged?

Question 2:

How to you bind a NULL value to a placeholder?  In DBI, you use undef
to stick a NULL into a query; in PEAR DB, I tried both null and an unset
variable, with the result that an empty string was placed into the query
string in both cases.


PHP Database Mailing List (
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to