php - SQLite3 Unable to write to database file on Amazon AWS but only in certain instances -
i have setup , ec2 instance on aws , part of instance using sqlite3 database handle data. of database operations routed through single php file, single connection:
function dataquery($query) { // establish database connection try { $dbh = new pdo(dbw); // try windows first $dbh->setattribute(pdo::attr_errmode, pdo::errmode_exception); } catch(pdoexception $e) { echo $e->getmessage(); $errorcode = $e->getcode(); // windows not available, try linux if('14' == $errorcode) { try { $dbh = new pdo(dbl); // try linux $dbh->setattribute(pdo::attr_errmode, pdo::errmode_exception); } catch(pdoexception $e) { echo $e->getmessage(); $errorcode = $e->getcode(); } } } // try run query try { $queryresults = $dbh->query($query); if($queryresults != null) { $results = $queryresults->fetchall(pdo::fetch_obj); // return object $queryresults = null; // closes connection return $results; } } catch(pdoexception $e) { $errormsg = $e->getmessage(); return $errormsg; } }
dbw
, dbl
constants defined couple of lines earlier. error getting:
could not find driver
"why strange?". ask. "because problem not consistent.", answer. let me elaborate...
the first action taking place when goes website login requires reading , writing database. this works fine (as application on 'normal' server).
2|jay blanchard|jayblanchard@thewebsite.com|foo|{"roles":["admin", "surveyor"]}|2015-06-04 15:32:29|69.1.164.40
there couple of other places reads occur , writes don't. writing works.
i have followed on dozen links pretty saying file permissions wrong. have followed file permissions instances on servers working , faithfully replicated them:
drwxrwxrwx 10 ubuntu ubuntu 4096 jun 4 15:32 application-gateway
and inside directory database file itself:
-rwxrw-rw- 1 ubuntu ubuntu 65536 jun 4 15:32 application.db
all of files attempting access database have ubuntu
group , owner.
i have followed other links make sure pdo extensions included in /etc/php5/apache2/conf.d/
lrwxrwxrwx 1 root root 32 jun 3 15:29 05-opcache.ini -> ../../mods-available/opcache.ini lrwxrwxrwx 1 root root 28 jun 3 15:29 10-pdo.ini -> ../../mods-available/pdo.ini lrwxrwxrwx 1 root root 29 jun 3 15:29 20-json.ini -> ../../mods-available/json.ini lrwxrwxrwx 1 root root 31 jun 3 15:33 20-mysqli.ini -> ../../mods-available/mysqli.ini lrwxrwxrwx 1 root root 30 jun 3 15:33 20-mysql.ini -> ../../mods-available/mysql.ini lrwxrwxrwx 1 root root 34 jun 3 15:33 20-pdo_mysql.ini -> ../../mods-available/pdo_mysql.ini lrwxrwxrwx 1 root root 33 jun 3 15:29 20-readline.ini -> ../../mods-available/readline.ini lrwxrwxrwx 1 root root 35 jun 3 20:17 pdo_sqlite.ini -> ../../mods-available/pdo_sqlite.ini
i not sure missing here. driver there , works read. driver doesn't change positions during write and writes occuring.
confirming pdo driver available php -
have got aws instance configured wrong?
after hours of reading , kibitzing , scratching head, figured out causing issue.
the application uses mixture of web , command-line calls database depending on action being taken. these include full-time services, cron jobs , exec's of php scripts other scripts outside of web-server. able track issue down difference between php web , php cli.
while of these services use script, shown above, connect database , run queries, location of drivers dependent on origination of request. if request originates command line call included file (above) treats if resources should available command line.
the drivers sqlite3 needed included in configuration files php cli. once reference sqlite drivers made in php cli, began work designed.
ubuntu@foo:/etc/php5/cli/conf.d$ ls -la total 8 drwxr-xr-x 2 root root 4096 jun 4 19:16 . drwxr-xr-x 3 root root 4096 jun 3 15:29 .. lrwxrwxrwx 1 root root 32 jun 3 15:29 05-opcache.ini -> ../../mods-available/opcache.ini lrwxrwxrwx 1 root root 28 jun 3 15:29 10-pdo.ini -> ../../mods-available/pdo.ini lrwxrwxrwx 1 root root 29 jun 3 15:29 20-json.ini -> ../../mods-available/json.ini lrwxrwxrwx 1 root root 31 jun 3 15:33 20-mysqli.ini -> ../../mods-available/mysqli.ini lrwxrwxrwx 1 root root 30 jun 3 15:33 20-mysql.ini -> ../../mods-available/mysql.ini lrwxrwxrwx 1 root root 34 jun 3 15:33 20-pdo_mysql.ini -> ../../mods-available/pdo_mysql.ini lrwxrwxrwx 1 root root 35 jun 4 19:15 20-pdo_sqlite.ini -> ../../mods-available/pdo_sqlite.ini lrwxrwxrwx 1 root root 33 jun 3 15:29 20-readline.ini -> ../../mods-available/readline.ini lrwxrwxrwx 1 root root 32 jun 4 19:16 20-sqlite3.ini -> ../../mods-available/sqlite3.ini
Comments
Post a Comment