I created connection to database, but I dont know why it always create a new empty database.sql file. When I rename the database file he creates always a new file instead giving me an error.
Here is my code
$db = new PDO("sqlite:".__DIR__."/database.sql");
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
This is the expected behaviour. When SQLite is called, it looks for the filename specified.
$db = new PDO("sqlite:".__DIR__."/database.sql");
If the database.sql file is not found, it will attempt to create the file.
As an aside, you might want to change the file extension from .sql to .sqlite for clarity.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With