Hi
I have the code below in my CC6 where conditions rules list for a db reader. My Model name is "modhead" for a table named deliveryheads. The interesting column name for this question is contactno. I want to get the logged in users group-names. Pick out the first chars before _ (this is the contactno for the logged in user) and use that in a sql statement. Everything except returning the correct array works below. I would expect CC to interpret it all into "where contactno in (123,456,789)".
My question is what to return to create such sql-statement?
Mattias
I have the code below in my CC6 where conditions rules list for a db reader. My Model name is "modhead" for a table named deliveryheads. The interesting column name for this question is contactno. I want to get the logged in users group-names. Pick out the first chars before _ (this is the contactno for the logged in user) and use that in a sql statement. Everything except returning the correct array works below. I would expect CC to interpret it all into "where contactno in (123,456,789)".
My question is what to return to create such sql-statement?
<?phpRegards
$user = JFactory::getUser();
$groups = $user->get('groups');
$db = JFactory::getDBO();
$elm = array();
foreach ($groups as $group)
{
$db->setQuery($db->getQuery(true)
->select('title')
->from("#__usergroups")
->where("id" . ' = ' . $group)
);
$groupsdb = $db->loadRowList();
foreach ($groupsdb as $groupdb) {
$contact = substr($groupdb[0],0, strpos($groupdb[0], '_'));
if ($contact)
{
array_push($elm, $contact);
}
}
}
$return = array('modhead.contactno/in:' => $elm);
return $return
?>
Mattias