Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Location_RecordSearchCriteria extends SearchCriteria {
- const NONE = -1;
- function __construct() {
- parent::__construct(
- array('Id', 'Country', 'State', 'City'),
- array('Id', 'Rand'));
- $this->setState(self::NONE);
- $this->setCity(self::NONE);
- $this->orderById();
- }
- }
- // ------------------------------
- protected function prepareFilters(array& $where, array& $binds,
- SearchCriteria $criteria)
- {
- if ( sizeof($list = $criteria->getId()) > 0 ) {
- $where[] = 'id IN (?' . str_repeat(',?', sizeof($list) - 1) . ')';
- $binds = array_merge($binds, $list);
- }
- if ( sizeof($list = $criteria->getCountry()) > 0 ) {
- for ( $i = 0; $i < sizeof($list); $i ++ ) {
- if ( is_object($list[$i]) ) {
- $list[$i] = $list[$i]->getId();
- }
- }
- $where[] = 'country IN (?' .str_repeat(',?',sizeof($list)-1).')';
- $binds = array_merge($binds, $list);
- }
- if ( is_object($criteria->get1State())
- || $criteria->get1State() != Location_RecordSearchCriteria::NONE )
- {
- $this->complexListFilter($where, $binds, 'state',
- $criteria->getState());
- }
- if ( is_object($criteria->get1City())
- || $criteria->get1City() != Location_RecordSearchCriteria::NONE )
- {
- $this->complexListFilter($where,$binds,'city',$criteria->getCity());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement