1

I'm trying to DESCRIBE a table in joomla 3.x I want to get the column names and the associated details (type etc) into an array.

I want to get

Name Type Collation Attributes Null Default Comments Extra

for any given table

I can't find anything in Joomla that tells me how to do that I think the way to go is to use DESCRIBE but I can't find anything in the API that allows me to do DESCRIBE. I've tried lots of ways of getting the info but no success e.g:

$db = JFactory::getDbo();
$query = $db->getQuery(true);   
$query = "DESCRIBE `##__table_person`";
$row = $db->loadObjectList($query);
/*while($row ) {
    echo "{$row['Field']} - {$row['Type']}\n";
}*/
print "<pre>";
print_r($row);
print "</pre>";
exit;
2

This will return an array of objects:

$db = JFactory::getDbo();
$result = $db->setQuery('DESCRIBE ' . $db->quoteName('#__table_person'))->loadObjectList();

Use loadAssocList() instead of loadObjectList() to return an array of associated arrays.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.