Welcome Guest, Not a member yet? Register   Sign In
Codeigniter equivalent to Joomla loadAssocList('key')
#1

[eluser]Unknown[/eluser]
Hi,

I am new to CI and would like to know if there are an equivalent for this joomla command, here is what it does.

loadAssocList($key)
loadAssocList('key') returns an associated array - indexed on 'key' - of associated arrays from the table records returned by the query:
. . .
$db->setQuery($query);
$row = $db->loadAssocList('username');
print_r($row);
will give (with line breaks added for clarity):
Array (
[johnsmith] => Array ( [id] => 1 [name] => John Smith [email] => [email protected] [username] => johnsmith )
[magdah] => Array ( [id] => 2 [name] => Magda Hellman [email] => [email protected] [username] => magdah )
[ydegaulle] => Array ( [id] => 3 [name] => Yvonne de Gaulle [email] => [email protected] [username] => ydegaulle )
)
You can access the individual rows by using:
$row['key_value'] // e.g. $row['johnsmith']
and you can access the individual values by using:
$row['key_value']['column_name'] // e.g. $row['johnsmith']['email']

I did not find anything on Google and did not find anything to match it in User docs under query results or Array helper.

Any help would be appreciated.





Theme © iAndrew 2016 - Forum software by © MyBB