icthos Posted November 28, 2012 Share Posted November 28, 2012 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 Quote Link to comment https://forums.phpfreaks.com/topic/271319-nightmare-joomla-problem-that-should-be-easy/ Share on other sites More sharing options...
icthos Posted November 28, 2012 Author Share Posted November 28, 2012 Its cool I found the answer. $this->records = $db->loadResult(); Should be $this->records = $db->loadRowList(); Quote Link to comment https://forums.phpfreaks.com/topic/271319-nightmare-joomla-problem-that-should-be-easy/#findComment-1396058 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.