MDB2: problem with prepare statement

From: Date: Mon, 04 Jul 2005 15:59:52 +0000
Subject: MDB2: problem with prepare statement
Groups: php.pear.general 
Request: Send a blank email to pear-general+get-19864@lists.php.net to get a copy of this message
Hi All, I've begun using MDB2 and I've struck a problem with preparing a statement. I'd like to use it to make synchronizing updates from my local mysql server to my remote server easier. My (mysql) recordsets are a collection of VARCHAR, TEXT, DATETIME and ENUM fields, and I'm not sure if I'm deriving these into the appropriate types for the statement preparation. For testing purposes, I'm starting simply with two VARCHAR fields. <? $fromdb =& connectMDB2(); // connection to local server $todb =& conenctRemoteMDB2(); // remote server $locsql = "SELECT title, subtitle FROM articles"; $locrs = $fromdb->query($locsql); while ($d = $locrs->fetchRow(MDB2_FETCH_ASSOC)){ $stmt = $todb->prepare("INSERT INTO articles (title, subtitle) VALUES (?, ?)", array('text','text')); $stmt->bindParamArray($d); $stmt->execute(); } $locrs->free(); ?> This code isn't working. Because of the scarcity of MDB2 documentation, I'm not sure why, and I'm not sure how to test for an error to find out why. The code 'executes' -- ie, if I put an echo within the while block it will display the same number of times as there are records in the source table. However, when I check the destination table on the remote server, it remains empty. So, a couple of questions -- can anyone see anything I'm doing wrong above? 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: $stmt = $todb->prepare("INSERT INTO articles (title, subtitle, display) VALUES (?, ?, 'Yes')", array('text', 'text')); And finally, how do I test for errors with MDB2? Any help immensely appreciated! Many thanks, Murray

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