---
title: "讀書筆記(Master joomla1.5第三章The database 02)"
author: "ltwoini"
date: "2010-07-06T15:19:00Z"
tags: ["Blog", "Cache"]
categories: ["编程语言"]
slug: "master-joomla1-5-the-database-02"
draft: false
lastmod: "2010-07-06T15:19:00Z"
id: 706631
url: "https://ltwoini.iteye.com/blog/706631"
---

**loadAssocList:**

public function test\_loadAssocList(){  
  echo " loadAssocList:\\n";  
  $this-&gt;assertNotNull($this-&gt;db);  
  $query = "SELECT * FROM "  
   .$this-&gt;db-&gt;nameQuote('#\_\_newsfeeds');  
  $this-&gt;db-&gt;setQuery($query);  
  print\_r($this-&gt;db-&gt;loadAssocList());//**散列數組 以num為key**  
  echo "\\nkey:name:\\n";  
  print\_r($this-&gt;db-&gt;loadAssocList('name'));//**散列數組 以column:'name'為key**  
 }

 

echo:

Array  
(  
    \[0] =&gt; Array  
        (  
            \[catid] =&gt; 4  
            \[id] =&gt; 1  
            \[name] =&gt; Joomla! Announcements  
            \[alias] =&gt; joomla-official-news  
            \[link] =&gt; [http://feeds.joomla.org/JoomlaAnnouncements](http://feeds.joomla.org/JoomlaAnnouncements)  
            \[filename] =&gt;  
            \[published] =&gt; 1  
            \[numarticles] =&gt; 5  
            \[cache\_time] =&gt; 3600  
            \[checked\_out] =&gt; 0  
            \[checked\_out\_time] =&gt; 0000-00-00 00:00:00  
            \[ordering] =&gt; 1  
            \[rtl] =&gt; 0  
        )

    \[1] =&gt; Array  
        (  
            \[catid] =&gt; 4  
            \[id] =&gt; 2  
            \[name] =&gt; Joomla! Core Team Blog  
            \[alias] =&gt; joomla-core-team-blog  
            \[link] =&gt; [http://feeds.joomla.org/JoomlaCommunityCoreTeamBlog](http://feeds.joomla.org/JoomlaCommunityCoreTeamBlog)  
            \[filename] =&gt;  
            \[published] =&gt; 1  
            \[numarticles] =&gt; 5  
            \[cache\_time] =&gt; 3600  
            \[checked\_out] =&gt; 0  
            \[checked\_out\_time] =&gt; 0000-00-00 00:00:00  
            \[ordering] =&gt; 2  
            \[rtl] =&gt; 0  
        )

   )  
key:name:  
Array  
(  
    \[Joomla! Announcements] =&gt; Array  
        (  
            \[catid] =&gt; 4  
            \[id] =&gt; 1  
            \[name] =&gt; Joomla! Announcements  
            \[alias] =&gt; joomla-official-news  
            \[link] =&gt; [http://feeds.joomla.org/JoomlaAnnouncements](http://feeds.joomla.org/JoomlaAnnouncements)  
            \[filename] =&gt;  
            \[published] =&gt; 1  
            \[numarticles] =&gt; 5  
            \[cache\_time] =&gt; 3600  
            \[checked\_out] =&gt; 0  
            \[checked\_out\_time] =&gt; 0000-00-00 00:00:00  
            \[ordering] =&gt; 1  
            \[rtl] =&gt; 0  
        )

    \[Joomla! Core Team Blog] =&gt; Array  
        (  
            \[catid] =&gt; 4  
            \[id] =&gt; 2  
            \[name] =&gt; Joomla! Core Team Blog  
            \[alias] =&gt; joomla-core-team-blog  
            \[link] =&gt; [http://feeds.joomla.org/JoomlaCommunityCoreTeamBlog](http://feeds.joomla.org/JoomlaCommunityCoreTeamBlog)  
            \[filename] =&gt;  
            \[published] =&gt; 1  
            \[numarticles] =&gt; 5  
            \[cache\_time] =&gt; 3600  
            \[checked\_out] =&gt; 0  
            \[checked\_out\_time] =&gt; 0000-00-00 00:00:00  
            \[ordering] =&gt; 2  
            \[rtl] =&gt; 0  
        )

)