當前位置: 首頁>>代碼示例>>PHP>>正文


PHP DatabaseObject::BuildMultiple方法代碼示例

本文整理匯總了PHP中DatabaseObject::BuildMultiple方法的典型用法代碼示例。如果您正苦於以下問題:PHP DatabaseObject::BuildMultiple方法的具體用法?PHP DatabaseObject::BuildMultiple怎麽用?PHP DatabaseObject::BuildMultiple使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在DatabaseObject的用法示例。


在下文中一共展示了DatabaseObject::BuildMultiple方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: GetLocations

 public static function GetLocations($db, $options = array())
 {
     $defaults = array('post_id' => array());
     foreach ($defaults as $k => $v) {
         $options[$k] = array_key_exists($k, $options) ? $options[$k] : $v;
     }
     $select = $db->select();
     $select->from(array('l' => 'blog_posts_locations'), 'l.*');
     if (count($options['post_id']) > 0) {
         $select->where('l.post_id in (?)', $options['post_id']);
     }
     $data = $db->fetchAll($select);
     $locations = parent::BuildMultiple($db, __CLASS__, $data);
     return $locations;
 }
開發者ID:kalroot,項目名稱:phpweb20demo,代碼行數:15,代碼來源:BlogPostLocation.php

示例2: GetUsers

 public static function GetUsers($db, $options = array())
 {
     // initialize the options
     $defaults = array('offset' => 0, 'limit' => 0, 'order' => 'u.username');
     foreach ($defaults as $k => $v) {
         $options[$k] = array_key_exists($k, $options) ? $options[$k] : $v;
     }
     $select = self::_GetBaseQuery($db, $options);
     // set the fields to select
     $select->from(null, 'u.*');
     // set the offset, limit, and ordering of results
     if ($options['limit'] > 0) {
         $select->limit($options['limit'], $options['offset']);
     }
     $select->order($options['order']);
     // fetch user data from database
     $data = $db->fetchAll($select);
     // turn data into array of DatabaseObject_User objects
     $users = parent::BuildMultiple($db, __CLASS__, $data);
     if (count($users) == 0) {
         return $users;
     }
     $user_ids = array_keys($users);
     // load the profile data for loaded posts
     $profiles = Profile::BuildMultiple($db, 'Profile_User', array('user_id' => $user_ids));
     foreach ($users as $user_id => $user) {
         if (array_key_exists($user_id, $profiles) && $profiles[$user_id] instanceof Profile_User) {
             $users[$user_id]->profile = $profiles[$user_id];
         } else {
             $users[$user_id]->profile->setUserId($user_id);
         }
     }
     return $users;
 }
開發者ID:kalroot,項目名稱:phpweb20demo,代碼行數:34,代碼來源:User.php


注:本文中的DatabaseObject::BuildMultiple方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。