nilportugues / sql-repository

[PHP 7] SQL Repository implementation
http://nilportugues.com
MIT License
36 stars 3 forks source link

Not working with SQLite? #20

Open geekish opened 8 years ago

geekish commented 8 years ago

I'm trying to use this library in a project where I was previously using Doctrine's DBAL with an SQLite database. When I attempt to write to the database I get:

SQLSTATE[HY000]: General error: 8 attempt to write a readonly database

I was able to read from and write to it just fine previously, so I did some digging.

When creating my own Doctrine Connection, I must use the following code (with an actual path): DriverManager::getConnection([ 'path' => /path/to/database, 'driver' => 'pdo_sqlite' ]);

...while the SQL repository creates it via: DriverManager::getConnection(['pdo' => $pdo])

It seems SQLite requires it to be done a bit differently. Perhaps it would be best to allow the user to inject their own DBAL connection?

geekish commented 8 years ago

Never mind, getting the same error now whether I use my own DBAL connection or not.

I still would like to be able to inject an instance of Connection into SqlRepository instead of PDO, for when I get this working. :sweat_smile: