insert array of rows and not by args
Closed this issue · 3 comments
Hi,
It'll be super useful to insert multiple rows by array and not with arguments,
look at this example:
21, 'name'=>'PHP');
$tags[1] = array('id'=>22, 'name'=>'MySQL');
$tags[2] = array('id'=>23, 'name'=>'Javascript');
$db->tags()->insert($tags);
?>
for now we can only insert rows by passing them as arguments:
tags()->insert($tags[0],$tags[1], $tags[2]);
?>
this not very useful, when your rows created in code.
$fields = array(
array('value' => 10),
array('value' => 66),
array('value' => 100),
);
call_user_func_array(array($db->fields(),'insert'),$fields);
okay, still don't you think the more neutral way is better?
honestly i think it more depends on your POV, since I work with code that i would insert single rows more often i would multiple rows. i rather not have to wrap my code in arrays of arrays that only have a single array, or take a performance hit for the author having to detect if the passed argument is an array or an array of arrays. esp. since php gives me a way of passing an array of arrays to a function as a list of arguments.