Created
April 30, 2014 12:23
-
-
Save mockiemockiz/3bc1a574fefb490f8614 to your computer and use it in GitHub Desktop.
gfhgfhgfhgf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$select = new Select(); | |
$select->from('real_estate_property')->columns(array('*')); | |
$select->join( | |
'real_estate_property_image', | |
"real_estate_property.id = real_estate_property_image.propertyId", | |
array('path'), | |
$select::JOIN_LEFT | |
); | |
if ($cond) { | |
$spec = function (Where $where, $combination = Predicate::COMBINED_BY_AND) use ($cond) { | |
if (isset($cond['greaterThan'])) { | |
foreach ($cond['greaterThan'] as $k => $c) { | |
$where->greaterThan($k, (int)$c); | |
} | |
} | |
if (isset($cond['lessThanOrEqualTo'])) { | |
foreach ($cond['lessThanOrEqualTo'] as $k => $c) { | |
$where->lessThanOrEqualTo($k, (int)$c); | |
} | |
} | |
if (isset($cond['like'])) { | |
foreach ($cond['like'] as $k => $c) { | |
$where->like($k, '%' . $c . '%'); | |
} | |
} | |
if (isset($cond['equal'])) { | |
foreach ($cond['equal'] as $k => $c) { | |
$where->equalTo($k, $c); | |
} | |
} | |
}; | |
$select->where($spec); | |
} | |
if (!$group) { | |
$select->group(array('id')); | |
} else { | |
$select->group($group); | |
} | |
$select->order(array('insertDate' => 'DESC')); | |
// create a new result set based on the Album entity | |
$resultSetPrototype = new ResultSet(); | |
$resultSetPrototype->setArrayObjectPrototype(new RealEstatePropertyInputFilter()); | |
// create a new pagination adapter object | |
$paginatorAdapter = new DbSelect( | |
// our configured select object | |
$select, | |
// the adapter to run it against | |
$this->getAdapter(), | |
// the result set to hydrate | |
$resultSetPrototype | |
); | |
$paginator = new Paginator($paginatorAdapter); | |
return $paginator; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment