medoo::where_clause() issue
Hello,
Thank you for this nice framework.
I hit a problem using the where conditions :
$where = array(
"OR" => array(
"test" => "123",
"test" => "456",
)
);
$str = $db->where_clause($where);
echo $str;
//WHERE test = '456'
I want to get like this:
//WHERE test = '123' OR test = '456'
That`s because you cannot declare key-value array with duplicate key name. Not only PHP, but for most programming language.
$data = array(
'name' => 'foo',
'name' => 'bar'
);
echo $data['name']; // 'bar'
Any good idea to solve this?
My idea : $data = array('name' => array('foo', 'bar'));
On Jul 26, 2013, at 23:45, Catfan [email protected] wrote:
That`s because you cannot declare key-value array with duplicate key name. Not only PHP, but for most programming language.
$data = array( 'name' => 'foo', 'name' => 'bar' );
echo $data['name']; // 'bar' Any good idea to solve this?
— Reply to this email directly or view it on GitHub.
One solution currently could be:
$database->select("i20", "test", [ "OR" => [ "test" => [ "123" , "456" ] ]]);
results in
SELECT test FROM i20 WHERE test IN ('123','456')
I found a "bug" (?) resulting here:
$database->select("i20", "test", [ "OR" => [ "test" => [123], "test2" => [ 456 ] ]]);
This is what you're looking for:
SELECT test FROM i20 WHERE test IN (123) OR test2 IN (456)
If the columns in where/or-clause are the same, result is strange:
$database->select("i20", "test", [ "OR" => [ "test" => [123], "test" => [ 456 ] ]]); SELECT test FROM i20 WHERE test IN (456)
I think best solution currently is: $database->select("i20", "test", [ "test" => [ "123" , "456" ] ]); results in SELECT test FROM i20 WHERE test IN ('123','456')
Added