当前位置: 首页>>代码示例>>PHP>>正文


PHP ArrayUtils::joinArray方法代码示例

本文整理汇总了PHP中ArrayUtils::joinArray方法的典型用法代码示例。如果您正苦于以下问题:PHP ArrayUtils::joinArray方法的具体用法?PHP ArrayUtils::joinArray怎么用?PHP ArrayUtils::joinArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ArrayUtils的用法示例。


在下文中一共展示了ArrayUtils::joinArray方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getTopBuilder

    public static function getTopBuilder($count, $location = null)
    {
        if ($location) {
            $city = GeoCityApi::getCityByName($location['city']);
            if ($count) {
                $sql = 'SELECT * from user_builder_profile JOIN
						(SELECT builder_id from user_builder_rating r 
							GROUP BY r.builder_id 
							order by AVG(r.rate) DESC LIMIT ' . "{$count}" . ')
	 					AS ratings ON (user_builder_profile.id=ratings.builder_id) where city_id=' . "{$city->id}" . ' ORDER BY rand()';
            }
            $sql = 'SELECT * from user_builder_profile JOIN
						(SELECT builder_id from user_builder_rating r 
							GROUP BY r.builder_id 
							order by AVG(r.rate) DESC)
	 					AS ratings ON (user_builder_profile.id=ratings.builder_id) where city_id=' . "{$city->id}" . ' ORDER BY rand()';
            $properties = Yii::app()->db->createCommand($sql)->queryAll();
            $countProperties = count($properties);
            if ($countProperties < $count) {
                $total = $count - $countProperties;
                $sql = 'SELECT * from user_builder_profile JOIN
						(SELECT builder_id from user_builder_rating r 
							GROUP BY r.builder_id 
							order by AVG(r.rate) DESC)
	 					AS ratings ON (user_builder_profile.id=ratings.builder_id) where city_id!=' . "{$city->id}" . ' AND state_id=' . "{$city->state_id}" . ' ORDER BY rand() limit ' . "{$total}" . '';
                $propertiesState = Yii::app()->db->createCommand($sql)->queryAll();
                $properties = ArrayUtils::joinArray($properties, $propertiesState);
                $countProperties = count($properties);
                if ($countProperties < $count) {
                    $total = $count - $countProperties;
                    $sql = 'SELECT * from user_builder_profile JOIN
								(SELECT builder_id from user_builder_rating r 
									GROUP BY r.builder_id 
									order by AVG(r.rate) DESC)
			 					AS ratings ON (user_builder_profile.id=ratings.builder_id) where city_id!=' . "{$city->id}" . ' AND state_id!=' . "{$city->state_id}" . ' ORDER BY rand() limit ' . "{$total}" . '';
                    $propertiesCountry = Yii::app()->db->createCommand($sql)->queryAll();
                    $properties = ArrayUtils::joinArray($properties, $propertiesCountry);
                }
            }
        } else {
            if ($count) {
                $sql = 'SELECT * from user_builder_profile JOIN
						(SELECT builder_id from user_builder_rating r 
							GROUP BY r.builder_id 
							order by AVG(r.rate) DESC LIMIT ' . "{$count}" . ')
	 					AS ratings ON (user_builder_profile.id=ratings.builder_id) ORDER BY rand()';
            }
            $sql = 'SELECT * from user_builder_profile JOIN
						(SELECT builder_id from user_builder_rating r 
							GROUP BY r.builder_id 
							order by AVG(r.rate) DESC)
	 					AS ratings ON (user_builder_profile.id=ratings.builder_id) ORDER BY rand()';
            $properties = Yii::app()->db->createCommand($sql)->queryAll();
        }
        if ($properties) {
            return $properties;
        } else {
            return false;
        }
        /*$criteria=new CDbCriteria;
        	 $criteria->limit=$count;
        	 $criteria->order='rand()';
        	 $criteria->with = 'propertyRatings r';
        	 $criteria->order='MAX(AVG(r.rate))';
        	 $properties=Property::model()->findAll($criteria);
        	 if($properties)
        	 return $properties;
        	 else
        	 return false;*/
    }
开发者ID:romeo14,项目名称:wallfeet,代码行数:70,代码来源:BuilderProfileApi.php

示例2: getFeaturedProperties

 /**
  * This method gets the count and returns the featured properties
  * Returns the model if found.
  * Returns false if not found.
  *
  * @param string $count
  * @return model || boolean
  */
 public static function getFeaturedProperties($count, $location = null)
 {
     if ($location) {
         $city = GeoCityApi::getCityByName($location['city']);
         $criteria = new CDbCriteria();
         $criteria->condition = 'featured=:featured  AND city_id=:city';
         $criteria->params = array(':featured' => 1, ':city' => $city->id);
         if ($count) {
             $criteria->limit = $count;
         }
         $criteria->order = 'rand()';
         $properties = Property::model()->findAll($criteria);
         $countProperties = count($properties);
         if ($countProperties < $count) {
             $total = $count - $countProperties;
             $country = GeoCountryApi::getCountryByName($location['country']);
             $criteria = new CDbCriteria();
             $criteria->condition = 'featured=:featured  AND state_id=:state AND city_id!=:cityId';
             $criteria->params = array(':featured' => 1, ':state' => $city->state_id, ':cityId' => $city->id);
             $criteria->limit = $total;
             $criteria->order = 'rand()';
             $propertiesState = Property::model()->findAll($criteria);
             $properties = ArrayUtils::joinArray($properties, $propertiesState);
             $countProperties = count($properties);
             if ($countProperties < $count) {
                 $total = $count - $countProperties;
                 $criteria = new CDbCriteria();
                 $criteria->condition = 'featured=:featured  AND state_id!=:state AND city_id!=:cityId';
                 $criteria->params = array(':featured' => 1, ':state' => $city->state_id, ':cityId' => $city->id);
                 $criteria->limit = $total;
                 $criteria->order = 'rand()';
                 $propertiesState = Property::model()->findAll($criteria);
                 $properties = ArrayUtils::joinArray($properties, $propertiesState);
             }
         }
         if ($properties) {
             return $properties;
         } else {
             return false;
         }
     } else {
         $criteria = new CDbCriteria();
         $criteria->condition = 'featured=:featured';
         $criteria->params = array(':featured' => 1);
         if ($count) {
             $criteria->limit = $count;
         }
         $criteria->order = 'rand()';
         $properties = Property::model()->findAll($criteria);
         if ($properties) {
             return $properties;
         } else {
             return false;
         }
     }
 }
开发者ID:romeo14,项目名称:wallfeet,代码行数:64,代码来源:PropertyApi.php


注:本文中的ArrayUtils::joinArray方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。