|
= '".($RentLeft*10000)."' \n"; $sqlRentLeft .= " \n"; endif; // 賃料SQL(上限) if(! empty($RentRight)): $RentRightColumn = 'a.RentalPrice'; if(! empty($KyouekiFlg)): $RentRightColumn .= '+COALESCE(a.MaintenanceFee, 0)'; endif; if(! empty($ParkingFlg)): $RentRightColumn .= '+COALESCE(a.Parking, 0)'; endif; $sqlRentRight = " AND \n"; $sqlRentRight .= " ".$RentRightColumn." <= '".($RentRight*10000)."' \n"; $sqlRentRight .= " \n"; endif; // 賃料指定エラーの場合 if( !empty($RentLeft) & !empty($RentRight) & $RentLeft >= $RentRight): #$sqlRentLeft = NULL; $sqlRentRight = NULL; endif; // 専有面積SQL(下限) if(! empty($MonoLeft)): $MonoLeftColumn = 'a.Monopoly'; $sqlMonoLeft = " AND \n"; $sqlMonoLeft .= " ".$MonoLeftColumn." >= '".$MonoLeft."' \n"; $sqlMonoLeft .= " \n"; endif; // 専有面積SQL(上限) if(! empty($MonoRight)): $MonoRightColumn = 'a.Monopoly'; $sqlMonoRight = " AND \n"; $sqlMonoRight .= " ".$MonoRightColumn." <= '".$MonoRight."' \n"; $sqlMonoRight .= " \n"; endif; // 専有面積指定エラーの場合 if( !empty($MonoLeft) & !empty($MonoRight) & $MonoLeft >= $MonoRight ): #$sqlMonoLeft = NULL; $sqlMonoRight = NULL; endif; // 間取SQL if(! empty($LayoutID)): if(is_array($LayoutID)): $LayoutID = implode(',', $LayoutID); endif; $sqlLayout = " AND \n"; $sqlLayout .= " a.LayoutID in (".$LayoutID.") \n"; $sqlLayout .= " \n"; endif; // 築年SQL if(! empty($YearsType)): $sqlYears = " AND \n"; $sqlYears .= " DATE_ADD(a.Years, INTERVAL ".$YearsType." YEAR) >= '".$now."' \n"; $sqlYears .= " \n"; endif; // 駅歩SQL if(! empty($PawnType)): $sqlPawn = " AND \n"; $sqlPawn .= " a.PawnTime <= ".$PawnType." \n"; $sqlPawn .= " \n"; endif; // 設備SQL if(! empty($Equipment)): foreach($Equipment as $key => $value): $sqlEquipment .= " AND \n"; $sqlEquipment .= " a.Equipment".$value." = 1 \n"; endforeach; endif; // その他SQL if(! empty($Option)): foreach($Option as $key => $value): $sqlOption .= " AND \n"; $sqlOption .= " a.Option".$value." = 1 \n"; endforeach; endif; // 周辺施設SQL if(! empty($Surround)): foreach($Surround as $key => $value): $sqlSurround .= " AND \n"; $sqlSurround .= " a.Surround".$value." = 1 \n"; endforeach; endif; // 一覧表示件数SQL $res = DBF_strchk($DispNum, 'int', '4', '0'); if(! empty($res)): $DispNum = 30; endif; // 並び替えSQL switch($SortType): case 1: // 物件データの新しい順 $sqlSort = " a.`Update` DESC, "; break; case 2: // 沿線の駅順 $sqlSort = " b.RouteID, b.Sort DESC, b.ID, "; break; case 3: // 家賃の安い順 $sqlSort = " a.RentalPrice, "; break; case 4: // 広さ順 $sqlSort = " a.Monopoly DESC, "; break; case 5: // 築年数の新しい順 $sqlSort = " a.Years DESC, "; break; default: // 物件データの新しい順 $sqlSort = " a.`Update` DESC, "; endswitch; /*========================================================================= SQL実行 =========================================================================*/ $sql = NULL; $sql .= "SELECT \n"; $sql .= " \n"; $sql .= " a.ProductID, \n"; $sql .= " c.Name AS RouteName, \n"; $sql .= " b.Name AS StationName, \n"; $sql .= " a.Address, \n"; $sql .= " a.RentalPrice, \n"; $sql .= " a.MaintenanceFee, \n"; $sql .= " a.BusTime, \n"; $sql .= " a.PawnTime, \n"; $sql .= " a.RentalPrice * a.Fee AS Fee, \n"; $sql .= " a.RentalPrice * a.Deposit AS Deposit, \n"; $sql .= " a.GuaranteeMoney, \n"; $sql .= " a.CancellationMoney, \n"; $sql .= " d.Name AS LayoutName, \n"; $sql .= " a.Monopoly, \n"; $sql .= " e.Name AS ArticleName, \n"; $sql .= " f.Name AS StructureName, \n"; $sql .= " a.Years, \n"; $sql .= " a.Topics, \n"; $sql .= " a.imgFile1, \n"; $sql .= " a.imgFile2, \n"; $sql .= " a.imgFile3, \n"; $sql .= " a.imgFile4 \n"; $sql .= "FROM \n"; $sql .= " article_tbl AS a \n"; $sql .= " INNER JOIN station_mst AS b \n"; $sql .= " ON a.Station1 = b.ID \n"; $sql .= " AND b.Flg = 1 \n"; $sql .= " INNER JOIN route_mst AS c \n"; $sql .= " ON a.Route1 = c.ID \n"; $sql .= " AND c.Flg = 1 \n"; $sql .= " LEFT JOIN layout_mst AS d \n"; $sql .= " ON a.LayoutID = d.ID \n"; $sql .= " AND d.Flg = 1 \n"; $sql .= " LEFT JOIN articletype_mst AS e \n"; $sql .= " ON a.ArticleTypeID = e.ID \n"; $sql .= " AND e.Flg = 1 \n"; $sql .= " LEFT JOIN structure_mst AS f \n"; $sql .= " ON a.StructureID = f.ID \n"; $sql .= " AND f.Flg = 1 \n"; $sql .= "WHERE \n"; //$sql .= " `Update` IS NOT NULL\n"; // 情報有効期限での表示規制をする場合 $sql .= " (a.InformationExpirationDay IS NULL\n"; $sql .= " OR \n"; $sql .= " a.InformationExpirationDay >= '".$now."' \n"; $sql .= " ) \n"; $sql .= $sqlRoute; $sql .= $sqlStation; $sql .= $sqlDistrict; $sql .= $sqlArticle; $sql .= $sqlRentLeft; $sql .= $sqlRentRight; $sql .= $sqlMonoLeft; $sql .= $sqlMonoRight; $sql .= $sqlLayout; $sql .= $sqlYears; $sql .= $sqlPawn; $sql .= $sqlEquipment; $sql .= $sqlOption; $sql .= $sqlSurround; // 件数取得 $res = DBF_execsql($sql); if($res): $DataCnt = mysql_num_rows($res); else: $DataCnt = 0; endif; // 最終表示件数取得 if( $DataCnt<$DispNum | $DataCnt<$ds+$DispNum ): $de = $DataCnt; else: $de = $ds + $DispNum; endif; // 戻SQL処理 $sql .= "ORDER BY \n"; $sql .= $sqlSort."a.ID \n"; $sql .= "LIMIT \n"; $sql .= " ".$ds.", ".$DispNum." \n"; $sql .= " \n"; $res = DBF_execsql($sql); ?> 該当物件総数は 件です。 (現在表示物件 〜件) |