php-db | 2001062
Date: 06/30/01
- Next message: Frank M. Kromann: "Re: [PHP-DB] sybase function for MS-SQL Server"
- Previous message: Miles Thompson: "Re: [PHP-DB] how to preseve value of radio-butons when form is refreshed?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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.
-- Paul DuBois, paul <email protected>-- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-db-unsubscribe <email protected> For additional commands, e-mail: php-db-help <email protected> To contact the list administrators, e-mail: php-list-admin <email protected>
- Next message: Frank M. Kromann: "Re: [PHP-DB] sybase function for MS-SQL Server"
- Previous message: Miles Thompson: "Re: [PHP-DB] how to preseve value of radio-butons when form is refreshed?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

