Search code examples
joomla

jdatabase no numbers appearing in article


I am testing outputting a query in a article in Joomla 3.0.2 via Sorcerer.

When i output the array storing the query only values that are no numbers are appearing.

E.g. say i have 2 rows in a table called 'goofy' like this

  • id, description
  • 1, test
  • 2, test2

My code then looks like this

$query = "SELECT * FROM goofy";

$db->setQuery($query);

$results = $db->loadAssocList();

print_r($results);

The output I am getting in the article is like this;

Array ( [0] => Array ( [id] => [description] => test ) [1] => Array ( [id] => [description] => test2 ) )

Any ideas why the numbers wont output?


Solution

  • $db = JFactory::getDBO();
    $query = $db->getQuery(true);
    $query->select('*');
    $query->from('goofy');  
    $db->setQuery($query);    
    $results = $db->loadAssocList();   
    print_r($results);