问题描述
我正在使用Ubuntu + php + unixodbc + mdbtools处理.mdb文件.
每件事(连接+选择)都可以正常工作,但可以使用Insert或Update语句.
我的代码是这样的:
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
返回正确的结果,但是第二个抛出一个错误,该错误导致apache出现段错误.
我使用isql命令对其进行了测试.运行Select语句成功,但Update不成功.
$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
或
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
推荐答案
最后我找到了解决方案:
mdbtools 尚不能写入mdb文件.
At last I found a solution :
mdbtools can not write to mdb files yet.
使用简单的已编译Java应用程序是我们的解决方案.
Using simple compiled java application is our solution.
- 使用 Jackcess库创建一个简单的Java项目.
- 为Java应用程序启用CLI参数并使用所需的功能mdb文件.
- 您甚至可以使用CLI参数获取mdb文件路径.
- Create a simple java project with Jackcess library.
- Enable CLI params for java application and do what you want withmdb file.
- You can even get mdb file path with CLI params.
这篇关于unixODBC PHP Update语句错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!