I have no idea at all why this short script fails. I have an SQLite2
database with a table called "pizzas". This table has the three columns
"pizza_id", "pizza_name" and "pizza_description". And in the table there
are 5 datasets. Here is my sample script:
-------------------------------------------------------------------------
$db = Zend_Db::factory('Pdo_Sqlite', array(
'dbname' => './database/pizza.sqlite',
'sqlite2' => true,
));
$insertData = array(
'pizza_id' => '6',
'pizza_name' => 'Pizza',
'pizza_description' => 'Pizza Test',
);
$db->insert('pizzas', $insertData);
-------------------------------------------------------------------------
This causes a fatal error:
-------------------------------------------------------------------------
Fatal error: Uncaught exception 'Zend_Db_Statement_Exception' with
message 'SQLSTATE[HY000]: General error: 1 SQL logic error or missing
database' in
/home/devhost/zfbuch/ZendFramework-1.6.2/library/Zend/Db/Statement/Pdo.php:238
Stack trace: #0
/home/devhost/zfbuch/ZendFramework-1.6.2/library/Zend/Db/Statement.php(283):
Zend_Db_Statement_Pdo->_execute(Array) #1
/home/devhost/zfbuch/ZendFramework-1.6.2/library/Zend/Db/Adapter/Abstract.php(430):
Zend_Db_Statement->execute(Array) #2
/home/devhost/zfbuch/ZendFramework-1.6.2/library/Zend/Db/Adapter/Pdo/Abstract.php(220):
Zend_Db_Adapter_Abstract->query('INSERT INTO "pi...', Array) #3
/home/devhost/zfbuch/ZendFramework-1.6.2/library/Zend/Db/Adapter/Abstract.php(508):
Zend_Db_Adapter_Pdo_Abstract->query('INSERT INTO "pi...', Array) #4
/home/devhost/zfbuch/kapitel07/listing_07_07.php(30):
Zend_Db_Adapter_Abstract->insert('pizzas', Array) #5 {main} thrown in
/home/devhost/zfbuch/ZendFramework-1.6.2/library/Zend/Db/Statement/Pdo.php
on line 238
-------------------------------------------------------------------------
If I use $db->fetchAll('SELECT * FROM pizzas') to select all data it
works properly. Only the $db->insert() call throws this fatal error.
What could be wrong here? Can anyone help?
Thanks and best regards,
Ralf
没有评论:
发表评论