pass array to where
instead of
$query->where("post_id" , 1)->where("category_id" , 2);
i would like to
$query->where([
"post_id" => 1,
"category_id" => 2
]);
Edit:
i extendet the code by myself: src/Pixie/QueryBuilder/QueryBuilderHandler.php between line 608 and 609 i inserted
//if an array is given
if(is_array($key)){
foreach($key as $key => $value){
$cached = $this->where($key, $value);
}
return $cached;
}
I believe your suggestion is not improving the code directly. The way of defining the where is something personal. I like to see the where in multiple lines because its more clear how many wheres I am using.
yeah thats your opinion
I'm with @eL-Prova on this.
I would like have the same thing.
I think, current version is more read, then u propose. U unlikely transfer more then 2-3 parameters to query. Why use an array?
Common use for this is checking if the record exists:
$insert = [
'name' => 'John',
'age' => 35,
'sex' => 'Y',
etc...
];
if (!QB::table('my_table')->where($insert)->first())
QB::table('my_table')->insert($insert);
So this makes sense.