[英]Zend_Db_Table_Abstract Insertion fail
I am inserting data in to the database using Zend class Zend_Db_Table_Abstract. 我正在使用Zend类Zend_Db_Table_Abstract将数据插入数据库中。
However in some cases when I put long text in to text fields the query execution failed. 但是,在某些情况下,当我在文本字段中输入长文本时,查询执行将失败。 So I changed my code according to an answer in this site.
因此,我根据该站点上的答案更改了代码。 Finally my code looks.
终于我的代码看起来了。
$objSQL = $this->objDB->getAdapter()->getConnection()->query($sql);
$result = $objSQL->execute();
This fixed the issue. 这解决了问题。 However with this modification I can't update data in the database.
但是,通过此修改,我无法更新数据库中的数据。 IF I change my code to previous way as bellow, then it starts to update.
如果我将代码更改为以下方式,则开始更新。
$objSQL = $this->objDB->getAdapter()->prepare($sql);
$result = $objSQL->execute();
Can someone help me to fix this issue? 有人可以帮我解决此问题吗? Thank you.
谢谢。
I could fix the issue by changing the code. 我可以通过更改代码来解决此问题。 I decided to remove custom insert sql statements.
我决定删除自定义插入sql语句。 And I passed those to the Send_DB_Table as array.
然后将它们作为数组传递给Send_DB_Table。 It worked.
有效。
$this->objDB->getAdapter()->insert($tableName, $arrayData);
Thanks. 谢谢。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.