php - Is it possible to update multiple rows at the time using Zend_Db_Table? -


i have simple array.

$a = array(    array('id' => 2, 'year' => 2010),    array('id' => 3, 'year' => 2011) ); 

and have mysql table id primary key. update table this:

foreach ($a $v) {   $db->update($v, array('id = ?' => $v['id'])); } 

and $a contains 3700 rows. need create 1 big query instead of loop. how can it? thank in advance. sorry english.

what asking isn't done, use update() either set lot of records have same values or set 1 record have many differnt values.

one way around aggregate updates, using array ids year 2011 run this:

 $where = array();   // should contain ids need year set 2011  // e.g.  $where[] = array("id" => 3);   $db->update("table_name", array("year" => 2011), $where); 

doing reduce number of queries assuming have many rows same year. documentation here.

or use method like this

edit after op response

the nature of problem means cannot solved effeicently.

your asking way of updating 3,700 rows of data different sets of data. if sets of data different there no pattern can exploit in order make effeicent. finding patterns, rows same year, , using them advantage increase speed of query require brain enagement in form of array mashing noted regilero.


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -