Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- public function objects($dataPG)
- {
- $query = "SELECT * FROM `the_property` WHERE `addr` <> ' '";
- $ltr_binds = array();
- foreach( $dataPG as $k => $v )
- {
- if( !empty(trim($v)) && $v != ',' )
- {
- if( !in_array($k, array('start', 'last', 'go', 'all')) )
- {
- if( $k == 'price' )
- {
- list($start, $last) = explode(',', $v);
- if( !empty(trim($start)) )
- {
- $query .= ' AND `'.$k.'` >= ?';
- $ltr_binds[] = $start;
- }
- if( !empty(trim($last)) )
- {
- $query .= ' AND `'.$k.'` <= ?';
- $ltr_binds[] = $last;
- }
- } else
- {
- $query .= ' AND `'.$k.'` = ?';
- $ltr_binds[] = $v;
- }
- }
- }
- }
- // prepare & query
- $pq = $this->pdo->prepare($query);
- $pq->execute( $ltr_binds );
- return $pq->fetchAll(PDO::FETCH_ASSOC);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement