Sorry for asking probably a basic question, but I'm having a blackout.
If I have an array of arrays:
Array
(
[appsversion] => Array
(
[0] => appsversion='6.1.0.33'
[1] => appsversion='6.1.0.40'
),
[osversion] => Array
(
[0] => osversion='6.1.0.53'
[1] => osversion='6.1.0.42'
)
)
how do I please construct an SQL condition with OR and AND of it?
I.e. for something like:
$condition = '';
foreach ($CONDITIONS as $key => $value) {
# XXX I'm so lost here XXX
}
$sql = sprintf('select %s from mytable where %s', $condition);
$sth = $pg->prepare($sql);
$sth->execute();
I need the constructed string
(appsversion='6.1.0.33' OR appsversion='6.1.0.40') AND
(osversion='6.1.0.53' OR osversion='6.1.0.42')
or:
appsversion in ('6.1.0.33', '6.1.0.40') AND
osversion in ('6.1.0.53', '6.1.0.42')
Please give me few hints - to get my brain started again :-)