开发者

Zend Framework MySQL query() problem with inserting long text

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 ope开发者_运维技巧rations
[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?


This helps to avoid the problem (but still its not a solution for the problem):

try {
    $this->insert(...);
} catch (Exception $e) {
    $this->update(...);
}

EDIT:

another workaround found here: Zend_Db Query crashes on insert more than 358 characters

use this:

$this->getAdapter()->getConnection()->query();

instead of this:

$this->getAdapter()->query();


this->getAdapter()->getConnection()->query();

I have not update data longtext when I update query, It's work for me

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜