Billy R Baldwin - 2015-07-28 02:04:49
I need to find a way to assign variables to a multidimensional array coming from an associative array query. I have tried many methods, and can't seem to get it right. My current code is below.
class getIt{
//Query our content table using the built in JFactory class, and loadAssocList() function.
// this function returns an indexed array of objects from the table
public function getMainQuery(){
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select($db->quoteName(array('id', 'title', 'introtext', 'images', 'fulltext')));
$query->from($db->quoteName('#__content'));
$query->where($db->quoteName('state') . ' = '. $db->quote('1'));
$query->order('ordering DESC');
$db->setQuery($query);
$res = $db->loadAssocList();
foreach($res as $row => $innerArray){
foreach($innerArray as $innerRow => $value){
print_r($innerArray,$value);
}
}
}
}
In the end I essentially want to be able to use:
$list = new getIt();
echo $list->getMainQuery($arg1,$arg2));
Where $arg1 and $arg2 represent specific key and value I want to pass, to echo the values.