當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。