I tried to fix this with this code in my class extending Zend_Db_Table

public function publish($ids) {
$this->update(
 array('status' => self::ACTIVE),
$this->getAdapter()->quoteInto('id IN (?)', $ids, Zend_Db::INT_TYPE)
 );
}

and

public function fetchByIds($ids) {
 return $this->fetchAll(
$this->select()
->from($this->_name)
 ->where($this->getAdapter()->quoteInto($this->_name . '.id IN (?)', $ids,
Zend_Db::INT_TYPE))
->order('date DESC')
 );
}

but I still get similar error:

2010-05-20T10:08:40+02:00 ERR (3): exception
'Zend_Db_Adapter_Mysqli_Exception' with message 'User *** already has more
than 'max_user_connections' active connections' in
Zend/Db/Adapter/Mysqli.php:333
Stack trace:
#0 Zend/Db/Adapter/Abstract.php(832): Zend_Db_Adapter_Mysqli->_connect()
#1 Zend/Db/Adapter/Abstract.php(902): Zend_Db_Adapter_Abstract->quote('582',
NULL)
#2 Zend/Db/Select.php(1000): Zend_Db_Adapter_Abstract->quoteInto('table...',
'582', NULL)
#3 Zend/Db/Select.php(475): Zend_Db_Select->_where('table...', '582', NULL,
true)
...

Regards,
Saša Stamenković


On Wed, May 19, 2010 at 12:12 PM, Саша Стаменковић <umpir...@gmail.com>wrote:

> So, if I put
>
> $table->getAdapter()->beginTransaction();
>
> before, and
>
> $table->getAdapter()->commit();
>
> after for loop, it should help? I'm not sure about this, but I can try.
>
> Setting active is ok, this is enum, but you're right, I should go with one
> update query, doing it on Zend_Db_Table_Row level is stupid, don't know why
> I solved it this way at all.
>
> Thanks.
>
> Regards,
> Saša Stamenković
>
>
>
> On Wed, May 19, 2010 at 11:48 AM, Jurian Sluiman <
> subscr...@juriansluiman.nl> wrote:
>
>> You executes many queries in a for loop, absolutely not recommended. Use
>> transactions or even better, loop through all models and create one query:
>> UPDATE my_table SET status='ACTIVE' where id IN (1,2,3,4,5,6,7,8). Both
>> are
>> possible with ZF.
>>
>> Regards, Jurian
>>
>> PS. Why activate a record by setting a value to string "ACTIVE"? You
>> should
>> look at some performance guide and use a kind of boolean field to set the
>> state.
>> --
>> Jurian Sluiman
>> CTO Soflomo V.O.F.
>> http://soflomo.com
>>
>> On Wednesday 19 May 2010 11:42:57 umpirsky wrote:
>> > Anyone who knows how this works in the backround?
>> >
>> > It really kills the server. This error spam the error log, and site goes
>> > down, but I still can to connect to db from mysql client (other IP).
>>
>
>

Reply via email to