DB_DataObject multiple insert problem.

From: Date: Fri, 04 Jul 2003 17:53:54 +0000
Subject: DB_DataObject multiple insert problem.
Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-18007@lists.php.net to get a copy of this message
Hi, I'm having an odd problem with DB_DataObject. Under certain circumstances multiple rows are being inserted into the database when using ->insert() and ->find()/->fetch() on the same page. by some testing I've found that the double or triple insert doesn't happen during the call to ->insert() but it happens when ->find() and/or ->fetch() is called. The baffling thing about it is that this problem doesn't happen all the time. It happens about every 2nd or 3rd time I run the code. Has anyone seen anything like this before? Thanks, Matt Friedman. Here is the offending code: My config is below too: ------------------------------------------------------------------------------------------------------------------------------------ <?php require "include/common.php"; require "DB/DataObject.php"; require "include/DataObjects/sub_classes/DaoMessage.class.php"; require "symcor/lib/util/serializeParams.php"; ?> <p>some html...</p> <?php if( "true" == $_POST["from_editor"] ) { $params = decodeParams($_POST["params"]); $daoMessage = new DaoMessage; $daoMessage->debugLevel(1); $daoMessage->object_id = $daoMessage->getNextId(); $daoMessage->language = $_POST["composition_language"]; $daoMessage->xml = $_POST["message"]; $daoMessage->description = $params["description"]; $daoMessage->region_name = $_POST["region_name"]; $daoMessage->template_name = $_POST['template_name']; $daoMessage->insert(); } ?> <p>Some html...</p> <?php $daoMessage2 = new DaoMessage; if( !$daoMessage2->find() ) { print "<P>No messages can be found."; } else { while( $daoMessage2->fetch() ) { print "<P>". $daoMessage2->description; } } ?> </body> </html> ------------------------------------------------------------------------------------------------------------------------------------ array(12) { ["schema_location"]=> string(80) "/data/pdffactory1/vhosts/mfriedman/symcor/scripts/DataObjects/editor_test/schema" ["class_location"]=> string(83) "/data/pdffactory1/vhosts/mfriedman/communicator/www/editor_test/include/DataObjects" ["require_prefix"]=> string(12) "DataObjects/" ["class_prefix"]=> string(11) "DataObjects" ["ignore_sequence_keys"]=> string(0) "" ["extends_location"]=> string(17) "DB/DataObject.php" ["extends"]=> string(25) "Airmiles_DataObjects_Base" ["generator_class_rewrite"]=> string(0) "" ["debug"]=> string(1) "0" ["debug_ignore_updates"]=> string(1) "0" ["dont_die"]=> string(1) "0" ["database"]=> string(53) "mysql://editor_test:editor_test@localhost/editor_test" }

« previous php.pear.dev (#18007) next »