I use XAMPP with
- PHP Version 5.4.7
- PDO drivers - mysql, sqlite - enabled
- SQLite Library - 3.7.7.1 - enabled
- sqlite3 - SQLite3 module version - 0.7 - enabled
- sqlite3.extension_dir - no value - no value
- API Extensions - mysql,mysqli,pdo_mysql
So, if I understood well some tutorials, that's all I need to be able to start working.
So, in C:\xampp\htdocs\my_project I copied database.db file (sakila downloaded from here: http://ift.tt/1gUPNBc )
Then I created index.php that looks like this:
<?php
try {
$db = new PDO('sqlite:./database.db');
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch(Exception $e) {
echo 'Error: ';
echo $e->getMessage();
die();
}
and when I run this there are no errors. As you can see, my path is /database.db. If I change it to just
$db = new PDO('sqlite:.database.db');
no errors. Or without dot:
$db = new PDO('sqlite:database.db');
or absolute path - there are no errors.
Even worse, if I put wrong not existing .db name:
$db = new PDO('sqlite:daaaaaaaaaaaatabase.db');
also - there are no errors.
Can you tell me what am I doing wrong?
With all of the above paths I've tried the following:
$results = $db->query('select * from film');
var_dump($results);
die();
and I get "General error: 1 no such table", but the database.db has that table (I installed sqlite, opened that database in command line and checked - the database.db is OK).
Aucun commentaire:
Enregistrer un commentaire