0

Please help I am going crazy here. I have inherited a CodeIgniter site from a previous developer and he used an .sqlite file based database. I started getting the following error:

Error Number: HY000/8

attempt to write a readonly database

So I started debugging and dug deeper and deeper until I eventually got so frustrated with strange results I tried a real hardcore test of actually deleting the database file completely and the pages continued to load content from the database.

I then changed the database name in the hostname value of the database config and created a brand new empty database file with that new name, ran the migrations, seeded the data and it all works. But! If I set the hostname value back to the original database name it goes back to the earlier behaviour of somehow managing to load the content but giving readonly error when writing to it.

What the hell is going on! How is this possible? I have cleared the application/cache/database folder. Where is that data from the original database name being cached? What do I not understand about SQLite/CodeIgniter/Filesystems?

Martin Joiner
  • 3,529
  • 2
  • 23
  • 49
  • 1
    Is it __caching__? – u_mulder Aug 10 '17 at 20:18
  • 1
    are you sure it is the sqlite database that was used? check the `['driver]` index of teh database config array in database.php` file in config folder. – coderodour Aug 10 '17 at 20:19
  • Probably would have been better to just move or rename it, but I guess that's water under the bridge – Don't Panic Aug 10 '17 at 20:25
  • @coderodour 'dbdriver' is 'pdo', 'hostname' = 'sqlite:'.APPPATH.'db/my2050.sqlite' – Martin Joiner Aug 10 '17 at 20:30
  • @Don'tPanic Why would it be better to move or rename it? I'm experimenting in a dedicated development environment. The database contains no data that cannot be re-seeded with the migrations. Please enlighten me as to why my decision to delete it was so foolish. – Martin Joiner Aug 10 '17 at 20:34
  • 1
    Well, no, considering all that it sounds fine. Sorry for assuming the worst, but hey, my expectations have been rather diminished after spending a few years here in PHP land. – Don't Panic Aug 10 '17 at 20:38
  • have you tried flushing the browser and codeigniter(i.e `application/cache`) cache? – coderodour Aug 10 '17 at 20:40
  • @coderodour How do I flush the cache other than delete the contents of that folder? (which I have done BTW) – Martin Joiner Aug 10 '17 at 20:46
  • Did you also clear the browser history? (`Control+H` brings up history settings in most browsers) – coderodour Aug 10 '17 at 20:49
  • @coderodour I did better than that... I tried a completely different browser that had never loaded the app (Firefox instead of Chrome) and the application still delivered content from the database. – Martin Joiner Aug 10 '17 at 20:57
  • This "might" help you - https://stackoverflow.com/questions/3319112/sqlite-read-only-database – TimBrownlaw Aug 10 '17 at 22:59

0 Answers0