I'm using Ubuntu+php+unixodbc+mdbtools for working with .mdb file.
Every thing(connection+select) works good, but Insert or Update statements.
My code is something like this :
$mdbConnection = new \PDO("odbc:mdbdriver",$user , $password , array('dbname' =>$FileName) );
$SelectResult = $mdbConnection->query("Select * from Zone");
$UpdateResult = $mdbConnection->query("Update Zone Set ShahrCode = 99");
$SelectResult
returns correct result, but the second one throws an error that cause apache to segfault error.
I test it with isql command.Running Select statement is successful but Update is not.
#isql mdbdriver
+---------------------------------------+
| Connected! |
| |
| sql-statement |
| help [tablename] |
| quit |
| |
+---------------------------------------+
SQL>Update Zone Set ShahrCode = 99
Error at Line : syntax error near Update
syntax error near Update
Got no result for 'Update Zone Set ShahrCode = 99' command
[08001][unixODBC]Couldn't parse SQL
[ISQL]ERROR: Could not SQLExecute
Or
SQL> Update [Zone] Set ShahrCode = 99
Error at Line : syntax error near Update
syntax error near Update
Got no result for 'Update [Zone] Set ShahrCode = 99' command
[ISQL]ERROR: Could not SQLExecute
How should I fix this error ? Thanks all
At last I found a solution :
mdbtools can not write to mdb files yet.
MDB Tools currently has read-only support for Access 97 (Jet 3) and Access 2000/2002 (Jet 4) formats. Write support is currently being worked on and the first cut is expected to be included in the 0.6 release.
Using simple compiled java application is our solution.
exec('cd path/to/javaproject;java -cp .
YourJavaProject "mdbfilepath" "insert|update|or select"',$output);