当前位置: 首页>>代码示例>>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;未经允许,请勿转载。