MDB2: Problems with insert using placeholders

From: Date: Mon, 30 Oct 2006 08:10:55 +0000
Subject: MDB2: Problems with insert using placeholders
Groups: php.pear.general 
Request: Send a blank email to pear-general+get-25674@lists.php.net to get a copy of this message
I was just trying out mdb2 (latest release) and when unit testing a data mapper am coming across a bit of a problem. During the unit tests setUp i create a table with the following code: <?php $createTable = "CREATE TABLE IF NOT EXISTS news_articles_unit_test
                       (
                           id SMALLINT(5) NOT NULL AUTO_INCREMENT PRIMARY KEY,
                           article_headline TEXT NOT NULL,
                           article_text TEXT NOT NULL,
                           date_inserted DATETIME NOT NULL,
                           date_modified DATETIME NOT NULL,
                           approved ENUM('yes', 'no') DEFAULT 'no'
                       )";
?> After executing the query, the table is created fine. I then insert some sample data into this temporary table, using the following: <?php $sampleText = array(
                           array(
                                   'headline' => '<h1>First Headline<h1/>',
                                   'text' => 'First text<br />PHP 5.14 released!'
                                ),
                           array(
                                   'headline' => '<h1>Second Headline<h1/>',
                                   'text' => 'Second text<br />Mr Kipling releases new cake!'
                                ),
                           array(
                                   'headline' => '<h1>Third Headline<h1/>',
                                   'text' => 'Third text'
                                ),
                           array(
                                   'headline' => '<h1>Fourth Headline<h1/>',
                                   'text' => 'Fourth text'
                                ),
                           array(
                                   'headline' => '<h1>Fifth Headline<h1/>',
                                   'text' => 'Fifth text'
                                )
                           );
       $sth = $this->db->prepare('INSERT INTO news_articles_unit_test (article_headline, article_text, date_inserted, date_modified) VALUES (?, ?, NOW(), NOW())', true, MDB2_PREPARE_MANIP);
       if(PEAR::isError($sth)) {
           die($sth->getMessage().' - '.$sth->getUserinfo());
       }
       foreach ($sampleText as $key=>$val)
       {
           $data = array($val['headline'], $val['text']);
           $result = $sth->execute($data);
           if(PEAR::isError($result)) {
               die($result->getMessage().' - '.$result->getUserinfo());
           }
       }
?> ....but i'm getting this error: "MDB2 Error: no such field - _doquery: [Error message: Could not execute statement] [Last query: SET @0 = Object] [Native code: 1054] [Native message: Unknown column 'Object' in 'field list'] " I'm using php 4.4.2 and mysql 3.23. What does the above error mean, and how can i fix it? Thanks. _________________________________________________________________ Windows Live™ Messenger has arrived. Click here to download it for free! http://imagine-msn.com/messenger/launch80/?locale=en-gb

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