beforeSave(false)) { return false; } $data = $this->_getFunctionData($attributes, true, true); if (!empty($data)) { $sql = 'SELECT ' . $this->_getDbCrudFunctionName('insert') . '(' . implode(', ', $this->_getPreparedFunctionData($data)) . ');'; $command = static::getDb()->createCommand(); $command->setSql($sql); $result = $command->execute(); $statement = $command->pdoStatement->fetchAll(); $this->setAttribute('id', $statement[0][0]); } else { $result = 0; } $this->afterSave(false); return $result; } protected function _changeStatus() { $sql = 'SELECT object_Update(' . static::getDb()->quoteValue($this->getAttribute('id')) . ', NUll, NULL, ' . static::getDb()->quoteValue($this->getAttribute('statusId')) . ', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);'; $command = static::getDb()->createCommand(); $command->setSql($sql); try { return $command->execute(); } catch (Exception $e) { return false; } } public static function getImageList($nodeId) { return Image::getNodeImageList($nodeId, ThumbGenerator::$thumbParams); } public function getRecommendUsers($ticketId, $namePart) { $linkedQuery = static::createQuery() ->select(['id']) ->from(['objectWithUserV ou']) ->where(['ou.objectId' => $ticketId, 'ou.roleId' => 'user']) ->andWhere('ou.id = u.id') ->limit(1); $query = static::createCastQuery() ->from(['userV u']) ->select(['u.id', 'u.name']) ->where(['u.roleId' => 'user', 'u.enabled' => 'y']) ->andWhere(['like', 'u.name', $namePart]) ->andWhere(['not exists', $linkedQuery]) ->orderBy('u.name') ->limit(10) ; return $query->createCommand()->queryAll(); } }