SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Thread: Zend_Db Sqlite?

  1. #1
    SitePoint Guru
    Join Date
    Jan 2005
    Location
    heaven
    Posts
    953
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Zend_Db Sqlite?

    I'm having a little bit of trouble using Zend_Db to access an sqlite database. I've verified that I can insert and retrieve data manually and I can retreive data using Zend_Db, but I can't seem to write to the database file. I've included the database schema, the being used to access the database as well as the stack trace. Can shed some light on what I've done wrong?

    log.db
    Code:
    CREATE TABLE "error_log" (
    "log_id" INTEGER PRImARY KEY, 
    "log_lvl" CHAR, 
    "log_date" DATETIME, 
    "log_msg" TEXT, 
    log_name varchar
    );
    
    insert into error_log (log_lvl,log_date,log_name,log_msg) values (1,'2008-12-01', 'Test', 'This is a test');
    Fetch Attempt
    PHP Code:
    $params = array(
        
    'dbname' => 'log.db'
    );
    $db Zend_Db::factory('PDO_SQLITE'$params);
    try
    {
        
    print_r($db->fetchAll('select * from error_log');
    }
    catch(
    Zend_Db_Exception $e)
    {
        
    print_r($e);

    Fetch output
    Code:
    Array ( [0] => Array ( [log_id] => 1 [log_lvl] => 1 [log_date] => 2008-12-01 [log_msg] => This is a test [log_name] => Test ) )
    Insert attempt
    PHP Code:
    $params = array(
        
    'dbname' => 'log.db'
    );
    $db Zend_Db::factory('PDO_SQLITE'$params);
    try
    {
        
    $db->insert('error_log', array('log_name'=>'asf'));
    }
    catch(
    Zend_Db_Exception $e)
    {
        
    print_r($e);

    Stack Trace
    Code:
    exception 'Zend_Db_Statement_Exception' with message 'SQLSTATE[HY000]: General error: 1 SQL logic error or missing database' in /usr/share/php5/Zend/1.7.0/Zend/Db/Statement/Pdo.php:238
    Stack trace:
    #0 /usr/share/php5/Zend/1.7.0/Zend/Db/Statement.php(283): Zend_Db_Statement_Pdo->_execute(Array)
    #1 /usr/share/php5/Zend/1.7.0/Zend/Db/Adapter/Abstract.php(430): Zend_Db_Statement->execute(Array)
    #2 /usr/share/php5/Zend/1.7.0/Zend/Db/Adapter/Pdo/Abstract.php(220): Zend_Db_Adapter_Abstract->query('INSERT INTO "er...', Array)
    #3 /usr/share/php5/Zend/1.7.0/Zend/Db/Adapter/Abstract.php(508): Zend_Db_Adapter_Pdo_Abstract->query('INSERT INTO "er...', Array)
    #4 modules/office/controllers/ErrorController.php(30): Zend_Db_Adapter_Abstract->insert('error_log', Array)
    #5 /usr/share/php5/Zend/1.7.0/Zend/Controller/Action.php(494): Office_ErrorController->errorAction()
    #6 /usr/share/php5/Zend/1.7.0/Zend/Controller/Dispatcher/Standard.php(285): Zend_Controller_Action->dispatch('errorAction')
    #7 /usr/share/php5/Zend/1.7.0/Zend/Controller/Front.php(934): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http))
    #8 bootstrap.php(23): Zend_Controller_Front->dispatch()
    #9 index.php(19): Bootstrap::run()
    #10 {main}
    Last edited by imaginethis; Dec 2, 2008 at 21:59.
    Creativity knows no other restraint than the
    confines of a small mind.
    - Me
    Geekly Humor
    Oh baby! Check out the design patterns on that framework!

  2. #2
    SitePoint Guru
    Join Date
    Jan 2005
    Location
    heaven
    Posts
    953
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Bah... nvm -.- I'm an idiot and forgot to set the adequate permissions on the parent director >.<
    Creativity knows no other restraint than the
    confines of a small mind.
    - Me
    Geekly Humor
    Oh baby! Check out the design patterns on that framework!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •