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


PHP Listing::hasAttribute方法代码示例

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


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

示例1: searchAtIndex


//.........这里部分代码省略.........
     //        }
     if (isset($_GET['keywords']) && !empty($_GET['keywords'])) {
         $criteria->compare('t.keywordsearch', ActiveRecord::safeField($_GET['keywords']), true);
     }
     if (isset($_GET['LeaseTerm']) && !empty($_GET['LeaseTerm'])) {
         $criteria->compare('t.lease_term', ActiveRecord::safeField($_GET['LeaseTerm']));
     }
     if (isset($_GET['furnished']) && !empty($_GET['furnished'])) {
         $criteria->compare('t.furnished', ActiveRecord::safeField($_GET['furnished']));
     }
     if (isset($_GET['minimum_psf']) && !empty($_GET['minimum_psf'])) {
         $criteria->addCondition("t.search_psf >= " . (double) $_GET['minimum_psf']);
     }
     if (isset($_GET['maximum_psf']) && !empty($_GET['maximum_psf'])) {
         $criteria->addCondition("t.search_psf <= " . (double) $_GET['maximum_psf']);
     }
     //        if (isset($_GET['minimum_constructed']) && !empty($_GET['minimum_constructed'])) {
     //            $criteria->addCondition("t.constructed >= " . (double) $_GET['minimum_constructed']);
     //        }
     //        if (isset($_GET['maximum_constructed']) && !empty($_GET['maximum_constructed'])) {
     //            $criteria->addCondition("t.constructed <= " . (double) $_GET['maximum_constructed']);
     //        }
     if (isset($_GET['option']) && !empty($_GET['option'])) {
         foreach ($_GET['option'] as $key => $value) {
             if ($value == 1) {
                 //With photos only
                 //Listing
                 $aListingId = ProListingPhotos::getListListingId();
                 if (count($aListingId)) {
                     $criteria->addInCondition("t.id", $aListingId);
                 }
             } elseif ($value == 2) {
                 //With floor plan ( floor > 1)
                 $criteria->addCondition("t.floor_area > " . 1);
             }
         }
     }
     if (isset($_GET['listed_on']) && !empty($_GET['listed_on'])) {
         $currDate = date('Y-m-d');
         switch ($_GET['listed_on']) {
             case 1:
                 $currDate = date('Y-m-d', strtotime("{$currDate} -3 days")) . " 00:00:00";
                 $criteria->addCondition("t.date_listed > '{$currDate}'");
                 break;
             case 2:
                 $currDate = date('Y-m-d', strtotime("{$currDate} -7 days")) . " 00:00:00";
                 $criteria->addCondition("t.date_listed > '{$currDate}'");
                 break;
             case 3:
                 $currDate = date('Y-m-d', strtotime("{$currDate} -14 days")) . " 00:00:00";
                 $criteria->addCondition("t.date_listed > '{$currDate}'");
                 break;
             case 4:
                 $currDate = date('Y-m-d', strtotime("{$currDate} -30 days")) . " 00:00:00";
                 $criteria->addCondition("t.date_listed > '{$currDate}'");
                 break;
         }
     }
     if (isset($_GET['listing_type']) && $_GET['listing_type'] == 'sale' || isset($_GET['listing_for']) && $_GET['listing_for'] == 'for_sale') {
         $criteria->compare('t.listing_type', Listing::FOR_SALE);
     } else {
         $criteria->compare('t.listing_type', Listing::FOR_RENT);
     }
     // to get only company listing
     $criteria->addCondition('t.user_id IS NOT NULL AND t.user_id>0');
     $mListing = new Listing();
     /*         * * sort ** */
     $defaultSort = explode('.', Listing::DEFAULT_SORT_BY);
     $criteria->order = implode(' ', $defaultSort);
     /*         * * for sort at search form ** */
     if (isset($_GET['s_sort']) && !empty($_GET['s_sort'])) {
         // check valid $_GET['sort']
         $sSort = explode('.', $_GET['s_sort']);
         // $_GET['sort'] = name.desc
         if (count($sSort) == 2) {
             if ($mListing->hasAttribute($sSort[0]) && in_array($sSort[1], self::$aDirectionSort)) {
                 $criteria->order = implode(' ', $sSort);
             }
         }
     }
     /*         * * for sort at search form ** */
     if (isset($_GET['sort']) && !empty($_GET['sort'])) {
         // check valid $_GET['sort']
         $sSort = explode('.', $_GET['sort']);
         // $_GET['sort'] = name.desc
         if (count($sSort) == 2) {
             if ($mListing->hasAttribute($sSort[0]) && in_array($sSort[1], self::$aDirectionSort)) {
                 $criteria->order = implode(' ', $sSort);
             }
         }
     }
     /*         * * sort ** */
     /*         * * pageSize ** */
     $itemPerPage = Listing::DEFAULT_ITEM_PERPAGE;
     if (isset($_GET['pageSize'])) {
         $itemPerPage = (int) $_GET['pageSize'];
     }
     /*         * * pageSize ** */
     return new CActiveDataProvider('Listing', array('criteria' => $criteria, 'pagination' => array('pageSize' => $itemPerPage)));
 }
开发者ID:jasonhai,项目名称:onehome,代码行数:101,代码来源:Listing.php


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