'{item}_CreateByUser', 'update' => '{item}_UpdateByUser', 'delete' => '{item}_DeleteByUser', 'updateLocal' => '{item}_UpdateLocal' ); public static function getTicketImageSql($fieldTicketId) { $q = static::createQuery(); $q->select(['imageV.filenameFs']); $q->from(['imageV']); $q->where('imageV.nodeId = ' . static::getDb()->quoteColumnName($fieldTicketId)); $q->andWhere(['imageV.display' => 'y']); $q->orderBy('imageV.sorter'); $q->limit(1); return $q->createCommand()->getRawSql(); } public static function getTicketImageCountSql($fieldTicketId) { $q = static::createQuery(); $q->select(['COUNT(*)']); $q->from(['imageV']); $q->where('imageV.nodeId = ' . static::getDb()->quoteColumnName($fieldTicketId)); $q->andWhere(['imageV.display' => 'y']); $q->orderBy('imageV.sorter'); $q->limit(1); return $q->createCommand()->getRawSql(); } /** * @param int|array $ticketId * @param null|string $for "row"|"list" * * @return array|bool */ public static function getTicketTags($ticketId, $for = 'row') { if (empty($ticketId)) { return []; } $query = static::createQuery(); $query->from(['objectWithTagLinkedV owt']); // requiredForObject $query->select([ 'objectId key', 'srcTypeCode typeCode', 'srcTypeName typeName', 'srcInternalTypeId as internalTypeId', 'srcId id', 'objectId', 'srcName name', 'srcAttributeDataType dataType', 'srcRequired required', 'srcAttributeCode attributeCode', 'srcUofmPre uofmPre', 'srcUofmPost uofmPost', 'srcNumericValue numericValue', 'srcDecimalMin decimalMin', 'srcDecimalMax decimalMax', 'srcDecimalRound decimalRound', 'srcTextValue textValue', 'srcTextIsLong textIsLong', 'srcDatetimeValue datetimeValue', 'srcDatetimeName datetimeName', 'srcDatetimeOutputFormatJs datetimeOutputFormatJs', ]); $query->andWhere(['objectId' => $ticketId]); $query->andWhere(['linked' => 1]); $query->andWhere(['srcIsRoot' => 'n']); $query->andWhere('srcGeoRoot IS NULL'); $query->orderBy('srcTypeSorter, srcSorter'); if ('row' === $for) { $query->andWhere('srcDisplayInObject = "y"'); } elseif ('list' === $for) { $query->andWhere('srcDisplayInObjectList = "y"'); } if (is_array($ticketId)) { return $query->createCommand()->queryAll(PDO::FETCH_GROUP | PDO::FETCH_ASSOC); } else { return $query->createCommand()->queryAll(); } } public static function getTicketImages($ticketId) { $q = static::createQuery(); $q->select(['imageId', 'name', 'filenameFs']); $q->from(['imageV']); $q->where(['imageV.nodeId' => $ticketId, 'imageV.display' => 'y']); $q->orderBy('imageV.sorter'); return $q->createCommand()->queryAll(); } }