Jump to content

Nightmare Joomla Problem That Should Be Easy


icthos

Recommended Posts

Hey Forum,

 

I am writing a Joomla component extension. Im trying to get all the records out of the database and set to an array, which should be a piece of cake - think SELECT * FROM mytable;

 

Problem is when I use this code, it only returns one piece of data from one column, as a variable.

 

 

public function getRecords() {

$db =& JFactory::getDBO();

$query = 'SELECT * FROM #__sproj_proj';

$db->setQuery( $query );

$this->records = $db->loadResult();

return $this->records;

}

 

It should return the whole table. IE

 

###############################

| id | name | number |

| 1 | jane | 04983843947 |

| 2 | dave | 04748444784947 |

| 3 | mark | 54367747474754 |

###############################

 

but of course as a multi-dimensional array

 

$this->records (

1 (1, Jane, 04983843947)

2 (2, Dave, 04748444784947)

3 (3, Mark, 54367747474754)

)

 

But it just returns the first value it encounters and nothing else.

 

echo $this->records;

// Outputs '1'. The value of the first column of the first record.

 

Its driving me insane. One of those things that should be simple but you can't find the fix anywhere. Can anyone help?

Cheers,

icthos

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.