PHP with Zend Framework can't start a SQLite database? -


Trying to get a simple PHP / Zend Framework setup to create and manipulate a SQLite databse.

  & lt ;? Php require_once ("Zend / Db.php"); // Zend Framework $ db = Zend_Db :: Factory ('Pdo_Sqlite', array ("dbname" = & gt; "./test.sqlite3")); $ Sql ​​= "If the table does not exist then" create tab ". $ Db- & quot; quoteIdentifier (" configs ")." (". $ Db-> quoteIdentifier (" name ")." Text tap primary key, "$ db -> Quotation marker (" value ")." Text not faucet); "; $ sql; $ per second DB-> Query ($ SQL);  

In the form of SQL "Exchange does not make" the configuration when creating "(" name "text null is not the primary key) , Tap "value" text); ", which looks correct.

But I get ' Zend_Db_Statement_Exception ' with the 'SQLSTATE [HY000]' message: General Error: 14 Open the database file I have tried to move "pioneer on the variable" ./ "I have been unable to write", and have ensured that the PHP file is allowed to be written for everyone. " Tried to create a file with "test test.sqlite3 " and made sure that it is writeable by everyone

this PH P v5.2.10

Your code is working here (but Windows). Therefore the array ("dbname" => is not a syntax problem)

Some thoughts:

  • If If you are running the program from PHP as an Apache module, then does it work if the command is run by the line? What is the permission of the file created? Adjust the permissions for the Apache user accordingly.
  • If not works on top: strace your script ( strace php test.php ) and for output errors Check it out.
  • In that directory where ./ test.sqlite3 is being created, it should be readable by the user running PHP and writable. This is enough for a readable and writable test.sqlite3 , because sqlite also writes a temporary test.sqlite3-journal and writes that this directory should ensure that it is.
  • Try to use a full path for the database name.
  • Make sure the pdo and pdo_sqlite extensions are loaded (check the output of phpinfo ()) ). Also see that there is no conflict between system and php bundled SQLite labs.

Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -