php/sql database connection?

Joe

New member
Hi,

I got this table, but i don't know how it looks like(structure).
I've got no install sql scripts and can't use phpmyadmin.

So I want to find out the names of the columns. Using php inside a Joomla! component. I've got:

function getData(){

$query = "SELECT * FROM #__table";

$this->_db->setQuery($query);
$this->_rows = $this->_db->loadObjectList();
}

The database connection works. I've figured out one of the columns is called 'username'. I get a result for $this->_rows->username;

So, how can I find out the column titles? Is loadObjectList the right function to work with?
i don't need a hoster. i'm doing this for a friend, but he's not here right know, so i can't ask him for the details.
Thank you for your answers, but the problem is, i need to use oo-php for this. So if you know a method that does the same as mysql_fetch_row or something, let me know.
Solved! Thanks for your input. The SHOW command was useful.

I ended up using:

$query = "SHOW COLUMNS FROM `#__table`";

$this->_db->setQuery($query);
$this->_row = $this->_db->loadRowList();
$r = "";
for($i=0;$i<20;$i++){
$r = $r." <br> ".$this->_row[$i][0];
}
return $r;

not that nice but it works.
 
Back
Top