Zend Framework MySQL query() 插入长文本的问题
我有一个类:
class Content_IndexModel extends Zend_Db_Table_Abstract {}
并且我想使用以下方法将新行插入到某个表中:(
$this->getAdapter()->query();
我不能使用 insert() 方法,因为我需要放置“ON DUPLICATE KEY UPDATE ...”)
查询如下所示:
INSERT INTO some_table
VALUES (null, 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla quis pulvinar quam. Nulla quis pulvinar quam. Nulla quis pulvinar quam. Nulla quis pulvinar quam. Nulla quis pulvinar quam. Nulla quis pulvinar quam. Nulla quis pulvinar quam. Nulla quis pulvinar quam. Nulla quis pulvinar quam. Nulla quis pulvinar quam. Nulla quis pulvinar quam.')
如果我在文本字段中再添加一个字符我遇到了严重错误,apache 正在重新启动,日志为空,屏幕上没有任何内容 - 幻数是 342 - 如果我尝试插入更长的文本,服务器就会崩溃:
[Thu Jan 27 11:29:10 2011] [notice] Parent: child process exited with status 255 -- Restarting.
[Thu Jan 27 11:29:11 2011] [notice] Apache/2.2.11 (Win32) PHP/5.3.0 configured -- resuming normal operations
[Thu Jan 27 11:29:11 2011] [notice] Server built: Dec 10 2008 00:10:06
[Thu Jan 27 11:29:11 2011] [notice] Child 2540: Child process is running
[Thu Jan 27 11:29:11 2011] [notice] Child 2540: Acquired the start mutex.
[Thu Jan 27 11:29:11 2011] [notice] Child 2540: Starting 64 worker threads.
[Thu Jan 27 11:29:11 2011] [notice] Child 2540: Starting thread to listen on port 80.
我尝试过几个不同的表 - 总是 342 可以,343 和更多 - 错误。两个包含 342 个字符的文本字段也可以,但当其中之一较长时 - 错误。另一个 PHP 版本,5.2.11 而不是 5.3.0 - 同样的错误。将 ZF 从 1.10.8 升级到 1.11.2 - 同样的错误。
当我使用 phpMyAdmin 运行此查询时,一切正常,所以我认为问题出在 ZF 上。
有什么想法吗?
I have a class:
class Content_IndexModel extends Zend_Db_Table_Abstract {}
and I want to insert new row into some table using:
$this->getAdapter()->query();
(I can't use insert() method because I need to put "ON DUPLICATE KEY UPDATE ...")
Query looks like this:
INSERT INTO some_table
VALUES (null, 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla quis pulvinar quam. Nulla quis pulvinar quam. Nulla quis pulvinar quam. Nulla quis pulvinar quam. Nulla quis pulvinar quam. Nulla quis pulvinar quam. Nulla quis pulvinar quam. Nulla quis pulvinar quam. Nulla quis pulvinar quam. Nulla quis pulvinar quam. Nulla quis pulvinar quam.')
And if I add one more char to text field I have mega-fatal-error, apache is restarting, logs are empty, nothing on screen - magic number is 342 - if I try to insert longer text server is crashing:
[Thu Jan 27 11:29:10 2011] [notice] Parent: child process exited with status 255 -- Restarting.
[Thu Jan 27 11:29:11 2011] [notice] Apache/2.2.11 (Win32) PHP/5.3.0 configured -- resuming normal operations
[Thu Jan 27 11:29:11 2011] [notice] Server built: Dec 10 2008 00:10:06
[Thu Jan 27 11:29:11 2011] [notice] Child 2540: Child process is running
[Thu Jan 27 11:29:11 2011] [notice] Child 2540: Acquired the start mutex.
[Thu Jan 27 11:29:11 2011] [notice] Child 2540: Starting 64 worker threads.
[Thu Jan 27 11:29:11 2011] [notice] Child 2540: Starting thread to listen on port 80.
I've tried on few different tables - always 342 is ok, 343 and more - error. Two text fields with 342 chars are also ok, but when one of them is longer - error. Another PHP version, 5.2.11 instead of 5.3.0 - same error. Upgrading ZF from 1.10.8 to 1.11.2 - same error.
When I run this query with phpMyAdmin everything works ok, so I think problem is with ZF.
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这有助于避免问题(但仍然不是问题的解决方案):
编辑:
此处找到的另一种解决方法:Zend_Db 查询在插入超过 358 个字符时崩溃
使用此:
而不是此:
This helps to avoid the problem (but still its not a solution for the problem):
EDIT:
another workaround found here: Zend_Db Query crashes on insert more than 358 characters
use this:
instead of this:
当我更新查询时,我没有更新数据长文本,这对我有用
I have not update data longtext when I update query, It's work for me