Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.