_user, $field, $default); } public function setUser($user) { $this->_user = $user; return $this; } protected function _getAutocompleteSelect($type = null) { $select = $this->_db->select(); $select->from($this->_getPair('User'), self::getAutocompleteColumns($type)); $select->joinLeft($this->_getPair('Company', 'c'), '`c`.`id` = `User`.`companyId`', []); $select->where('User.`bought` = "y"'); $select->where('User.`status` = "active"'); $select->limit(10); if ('event' === $type) { $select->where('EXISTS (' . AttendeeModel::getUserSameCompanyExpr('User') . ')'); if (($userId = $this->getUser('id'))) { $select->where('User.id != ?', $userId, Qs_Db::INT_TYPE); $select->where('User.companyId = ?', $this->getUser('companyId'), Qs_Db::INT_TYPE); } else { $select->where('`c`.`status` = ?', CompanyEntity::STATUS_ACTIVE); } } elseif (AutocompleteObj::TYPE_TRADESHOW == $type) { $select->where('`c`.`status` = ?', CompanyEntity::STATUS_ACTIVE); if (($userId = $this->getUser('id'))) { $select->where('User.companyId = ?', $this->getUser('companyId'), Qs_Db::INT_TYPE); } } return $select; } }