Thesee pisze:
chrisweb wrote:
you could do it like this:

$stmt = $db->query('SELECT * FROM bugs LIMIT 100');

$rows = $stmt->fetchAll();

foreach ($rows as $row) {

     $db->query('UPDATE  bugs SET solved = 1 WHERE bug_id =
'.$row[bug_id']);

}


Thank you for answer, I know I can use fetchAll() method, but i have to use fetch() due the fact
fetchAll() can be a memory killer.
If I have a large amount of data (csv export, mass mailing send and so on) I
have to forgive fetchAll to prevent out of memory problem.
So I'm diggin to find a way to use query inside a fetch loop.....my opinion
is that it's a big bug on zend side.
All db layer i used can do this...i can't believe that zend_db cannot manage
this type of operations.

maybe i should fill a bug report?

Thank you


Hi

You can use Zend_Db_Statement http://framework.zend.com/manual/en/zend.db.statement.html

Example

$stmt = $db->query('SELECT * FROM bugs LIMIT 100');
|
while ($row = $stmt->fetch()) {
|     $db->query('UPDATE  bugs SET solved = 1 WHERE bug_id ='.$row[bug_id']);
|}|






Reply via email to