loadAssocList:
public function test_loadAssocList(){
echo " loadAssocList:\n";
$this->assertNotNull($this->db);
$query = "SELECT * FROM "
.$this->db->nameQuote('#__newsfeeds');
$this->db->setQuery($query);
print_r($this->db->loadAssocList());//散列數組 以num為key
echo "\nkey:name:\n";
print_r($this->db->loadAssocList('name'));//散列數組 以column:'name'為key
}
echo:
Array
(
[0] => Array
(
[catid] => 4
[id] => 1
[name] => Joomla! Announcements
[alias] => joomla-official-news
[link] => http://feeds.joomla.org/JoomlaAnnouncements
[filename] =>
[published] => 1
[numarticles] => 5
[cache_time] => 3600
[checked_out] => 0
[checked_out_time] => 0000-00-00 00:00:00
[ordering] => 1
[rtl] => 0
)
[1] => Array
(
[catid] => 4
[id] => 2
[name] => Joomla! Core Team Blog
[alias] => joomla-core-team-blog
[link] => http://feeds.joomla.org/JoomlaCommunityCoreTeamBlog
[filename] =>
[published] => 1
[numarticles] => 5
[cache_time] => 3600
[checked_out] => 0
[checked_out_time] => 0000-00-00 00:00:00
[ordering] => 2
[rtl] => 0
)
)
key:name:
Array
(
[Joomla! Announcements] => Array
(
[catid] => 4
[id] => 1
[name] => Joomla! Announcements
[alias] => joomla-official-news
[link] => http://feeds.joomla.org/JoomlaAnnouncements
[filename] =>
[published] => 1
[numarticles] => 5
[cache_time] => 3600
[checked_out] => 0
[checked_out_time] => 0000-00-00 00:00:00
[ordering] => 1
[rtl] => 0
)
[Joomla! Core Team Blog] => Array
(
[catid] => 4
[id] => 2
[name] => Joomla! Core Team Blog
[alias] => joomla-core-team-blog
[link] => http://feeds.joomla.org/JoomlaCommunityCoreTeamBlog
[filename] =>
[published] => 1
[numarticles] => 5
[cache_time] => 3600
[checked_out] => 0
[checked_out_time] => 0000-00-00 00:00:00
[ordering] => 2
[rtl] => 0
)
)