Joomla Indonesia

Login or Sign Up
Sign In or Register
Avatar
Not Registered Yet?

Join Now! It's FREE. Get full access and benefit from this site

Reset My password - Remind Me My username

Username
Password
Remember me
  • Home
    Home This is where you can find all the blog posts throughout the site.
  • Categories
    Categories Displays a list of categories from this blog.
  • Tags
    Tags Displays a list of tags that have been used in the blog.
  • Bloggers
    Bloggers Search for your favorite blogger from this site.
  • Team Blogs
    Team Blogs Find your favorite team blogs here.
  • Login
    Login Login form

Mengenal Database Class (loadAssocList)

Posted by on in Tutorial
  • Font size: Larger Smaller
  • Hits: 5360
  • 0 Comments
  • Subscribe to this entry
  • Print
Fungsi loadAssocList menghasilkan baris data dari table di database, penamaan index berdasarkan nama field.

Syntaxnya ditulisakan sebagai berikut.

{xtypo_code}array loadAssocList ( string $key ){/xtypo_code}
$key adalah nama field dari primary key. Parameter ini bersifat opsional dan jika tidak diisi maka defaultnya adalah kosong.

Contoh:

{xtypo_code}function getCategories() {
global $database;
$sql = 'SELECT * FROM #jos_categories';
$database->setQuery( $sql );
$rows = $database->loadAssocList();
print_r( $rows );
}
getCategories();{/xtypo_code}

Maka akan menghasilkan output sebagai berikut.

{xtypo_code}Array
(
[0] => Array
(
[id] => 1
[parent_id] => 0
[title] => Latest
[name] => Latest News
[image] => taking_notes.jpg
[section] => 1
[image_position] => left
[description] => The latest news from the Joomla Team
[published] => 1
[checked_out] => 0
[checked_out_time] => 2000-00-00 00:00:00
[editor] =>
[ordering] => 0
[access] => 0
[count] => 1
[params] =>
)
[1] => Array
(
[id] => 2
[parent_id] => 0
[title] => Joomla
[name] => Joomla
[image] => clock.jpg
[section] => com_weblinks
[image_position] => left
[description] => A selection of links that are all related to the Joomla project.
[published] => 1
[checked_out] => 0
[checked_out_time] => 0000-00-00 00:00:00
[editor] =>
[ordering] => 0
[access] => 0
[count] => 0
[params] =>
)
}{/xtypo_code}

0
  • No comments found

Kategori Blog

Joomla User Group Indonesia

Joomla User Group indonesia

Id-joomla.com adalah situs resmi Joomla User Group (JUG) Indonesia dan Joomla Translation Team

 
Download Terjemahan Joomla terakreditasi dari JoomlaCode dan laporkan bugs, ide dan saran nya di Sub Forum Hanacaraka

Socials

twitter id joomlafb idjoomla