Re: MDB2: problem with prepare statement
| From: | Lukas Smith | Date: | Mon, 04 Jul 2005 16:13:45 +0000 |
| Subject: | Re: MDB2: problem with prepare statement | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-19865@lists.php.net to get a copy of this message | ||
Murray @ PlanetThoughtful wrote:
are you using buffered result sets?
in that case it might be MySQL not wanting that you execute a query while a result set is still open.
the above fetchmode doesnt exist .. was this just a typo on your email?$locsql = "SELECT title, subtitle FROM articles";$locrs = $fromdb->query($locsql);while ($d = $locrs->fetchRow(MDB2_FETCH_ASSOC)){
Ah .. actually the problem is likely that you are using numeric placeholders, yet you are passing associatively keyed values. so either use MDB2_FETCHMODE_ORDERED or instead of using '?' placeholders append the column name from the select with a colon like: INSERT INTO articles (title, subtitle) VALUES (:title, :subtitle)$stmt = $todb->prepare("INSERT INTO articles (title, subtitle)VALUES (?, ?)", array('text','text'));$stmt->bindParamArray($d);$stmt->execute();}
Also, can anyone give me the MDB2 data type equivelants of VARCHAR, TEXT, DATETIME and ENUM fields? Also, can anyone tell me if it's possible to use static values within prepare statements? ie something like:VARCHAR is text TEXT is clob DATETIME is timestamp ENUM is text
$stmt = $todb->prepare("INSERT INTO articles (title, subtitle, display) VALUES (?, ?, 'Yes')", array('text', 'text'));yes
And finally, how do I test for errors with MDB2?the generic PEAR error checking .. PEAR::isError($result); or specificallyfor MDB2 errors .. MDB2::isError($result); regards, Lukas