Hy, i try to make a mysql query like
SELECT * FROM modx_site_tmplvar_contentvalues where tmplvarid = '8' and (value = '6' or value = '12')
but after run this in xpdo
$c->where(array(
'tmplvarid' => '8'
));
$c->andCondition(array(
'value' => '6'
), null, 1);
$c->orCondition(array(
'value' => '9'
), null, 1);
i get wrong result. Think i make the query wrong but i am new to xpdo and need your help. How to make a xpdo query like the mysql query above and how should it look for a query like this
SELECT * FROM mosega.modx_site_tmplvar_contentvalues where tmplvarid = '8' and (value = '18' or value = '12') or tmplvarid = '9' and (value like '%Action%' or value like '%komödie%') or tmplvarid = '58' and (value = 'P') order by contentid asc
I have the values in a array and need to run a loop to insert it into the query. Tried it with this code
if($_GET['u'] != ''){
//USK Conditions
$c = $modx->newQuery('modTemplateVarResource');
$c->select('*');
if(count($uskValues) == 1){
$c->where(array(
'tmplvarid' => '8',
'value' => $uskValues[0]
));
}else{
$c->where(array(
'tmplvarid' => '8'
));
$c->andCondition(array(
'value' => $uskValues[0]
), null, 1);
unset($uskValues[0]);
foreach($uskValues as $usk){
$c->orCondition(array(
'value' => $usk
), null, 1);
}
}
$elements = $modx->getCollection('modTemplateVarResource',$c);
$uskids = array();
foreach($elements as $element){
$uskids[] = $element->get('contentid');
}
}