How do I connect CakePHP to a SQLite database?
cakephp, sqlite
Solution
As of CakePHP 2.0, Sqlite 3 is supported out of the box.
Be sure that sqlite is enabled in your PHP configuration:
phpinfo();
Inside `app/Config/databases.php` you can define Sqlite database like this:
public $default = array(
'datasource' => 'Database/Sqlite',
'persistent' => false,
'database' => 'my_database_name',
'prefix' => '',
'encoding' => 'utf8',
);
Now check your `app/webroot/my_database_name.sqlite` file.
Problem
I have a rather basic problem: I can't seem to connect CakePHP to my SQLite database. Surprisingly, I didn't find lots of information about it on the internet, though I may be looking up the wrong keywords. Nevertheless, this is my connection code: ``` var $default = array( 'driver' => 'sqlite', 'connect' =>'sqlite_popen', 'persistent' => false, 'host' => 'localhost', 'port' => '', 'login' => '', 'password' => '', 'database' => '/home/MY_USER_NAME/public_html/my_database.sqlite', 'schema' => '', 'prefix' => '', 'encoding' => '' ); ``` Still, Cake only says "Cake is NOT able to connect to the database". Also, I don't know where to see the "real" logs (i.e., the error returned from the SQLite "driver"). So, I hit a dead-end. What should I do? Thanks in advance.