- 1
- 2
- 3
- 4
$data = $this->db->qp($q=(($type == 1 && $this->auth->demo == 0) ? '(SELECT Favorite_Name as s, CONCAT(oname,\'|\',House,\'|\',Enter) as s2, Id as id, \'1\' as t, null as m, IF(LEFT(LOWER(TRIM(Favorite_Name)), '.$c.')=\''.$sword.'\', 0, IF(LEFT(LOWER(TRIM(oname)), '.$c.')=\''.$sword.'\', 1, 2)) as od, \'1\' as t2 FROM :Cabinet_Favorite_Objects: WHERE Client_Phone=\'7'.$this->auth->phone.'\' && (lower(Favorite_Name) LIKE \'%'.$sword.'%\' || lower(oname) LIKE \'%'.$sword.'%\') ORDER BY od ASC, Favorite_Name'.$lim.')
UNION ALL
(SELECT addr as s, \'1\' as s2, id as id, \'2\' as t, null as m, IF(LEFT(LOWER(TRIM(addr)), '.$c.')=\''.$sword.'\', 0, 1) as od, \'2\' as t2 FROM :cabinet_history_objects: WHERE cid=\''.$this->auth->adata['IDClient'].'\' && lower(addr) LIKE \'%'.$sword.'%\' ORDER BY od ASC, num, addr DESC'.$lim.')
' : '').(($type == 1 && $this->auth->demo == 0 && $c > 0) ? ' UNION ALL ' : '').(($c > 0) ? '(SELECT objectName as s, objectMetaType as s2, objectID as id, \'3\' as t, objectAddress as m, IF(LEFT(LOWER(TRIM(SearchField)), '.$c.')=\''.$sword.'\', 0, 1) as od, IF(objectMetaType=\'0\', 3, IF(objectMetaType=\'100\', 4, 5)) as t2 FROM :Cabinet_Objects: WHERE lower(SearchField) LIKE \'%'.$sword.'%\' ORDER BY od ASC, objectMetaType ASC, s ASC'.$lim.')' : ''), '', 'select');