Created
February 12, 2015 16:00
-
-
Save enlacee/8e151d6c3c714a1c4c3f to your computer and use it in GitHub Desktop.
zf2-subqueyr-2
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 | |
$text = '*'.$textParam.'*'; | |
$id_district = (int) $district; | |
// subquery | |
$adapter = $this->table->getAdapter(); | |
$sql = new Sql($adapter); | |
$mainSelect = $sql->select()->from('searchs'); | |
$mainSelect->columns( | |
array( | |
'id_search', | |
'username_user', | |
'name', | |
'services_profile', | |
'id_user', | |
'id_district', | |
'relevance' => new \Zend\Db\Sql\Expression('MATCH (name,services_profile,username_user) AGAINST (? IN BOOLEAN MODE)', $text), | |
)) | |
->where("MATCH (name, services_profile, username_user) AGAINST ( '$text' IN BOOLEAN MODE) "); | |
if (!empty($id_district) && $id_district > 0) { | |
$mainSelect->where(array('id_district' => $id_district)); | |
} | |
$mainSelect->order('relevance DESC') | |
->limit(5); | |
//echo $sql->getSqlstringForSqlObject($mainSelect); exit ; | |
$resultSet = $this->table->selectWith($mainSelect); | |
$data = $resultSet->toArray(); | |
return $data; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment