I think this is a pretty nice idea, but maybe we want to add some sort of more dynamic and flexible solution.
I would like to see the ability to set each values operator (AND or OR)
So I could add something like this:
$intTestId = array('AND' => array('OR' => 12,'OR' => 13),'AND' => 14);
This should generate:
SELECT
Bla.blabla_id
Bla.blabla
FROM tblBla bla
WHERE
( blabla_id = 12 OR blabla_id = 13)
AND blabla_id = 14
This way we could define operator to use.
Actually the first key index is not used, but should be defined as something.
$intTestId = array('NOT_IN_USE' => 12,'AND' => 13,'AND' => 14,'OR' => 15);
This would generate this:
SELECT
Bla.blabla_id
Bla.blabla
FROM tblBla bla
WHERE
blabla_id = 12
AND blabla_id = 13
AND blabla_id = 14
OR blabla_id = 15
Also I think someone was working on creating a solution where you could define what field you wanted to add also.
Anyway I think everyone wants a easy way to load dataarrays with some sort of customized sql with more than one field in the where clause.
The optimal solution would be where we could pass some sort of array with information about the data we want.
maybe something like this:
$arrWhereClause = array(
array('clause_operator' => null,
'fieldname' => 'test_id',
'operator' => '=',
'value' => 12
),
array('clause_operator' => 'AND',
'fieldname' => 'name',
'operator' => 'LIKE',
'value' => 'somestring'
)
array('clause_operator' => 'OR',
'fieldname' => 'color',
'operator' => 'LIKE',
'value' => 'blue'
)
);
This sould generate:
SELECT
somefieldshere
FROM sometable
WHERE
test_id = 12
AND name LIKE 'somestring'
OR color LIKE 'blue'
The next step would be to group several fields to create something like this:
SELECT
somefieldshere
FROM sometable
WHERE
(
test_id = 12
AND name LIKE 'somestring'
)
OR color LIKE 'blue'
What do you think?