public function getAttributeVersions($attribute)
    {
        /** @var ActiveRecord $owner */
        $owner = $this->owner;
        return (new Query)
            ->select([
                'value' => "CASE action_type "
                    . "WHEN 'INSERT' THEN jsonb_object_field_text(row_data, :attribute::text) "
                    . "ELSE jsonb_object_field_text(changed_fields, :attribute::text) END",
                'action_id',
            ])
            ->from($this->auditTableName)
            ->where(['AND',
                'relation_id = \''.$owner->tableName().'\'::regclass',
                'statement_only = false',
                ['OR',
                    ['AND', 'action_type = \'INSERT\'', "jsonb_exists(row_data, :attribute)"],
                    ['AND', 'action_type = \'UPDATE\'', "jsonb_exists(changed_fields, :attribute)"],
                ],
                'row_data @> :primaryKey',
            ], [
                //':tableName' => $owner->tableName(),
                ':attribute' => $attribute,
                ':primaryKey' => json_encode($owner->getPrimaryKey(true)),
            ])
            ->orderBy('action_id')
            ->indexBy('action_id')
            ->column($owner->getDb());
    }
public function getAttributeVersions($attribute)
    {
        /** @var ActiveRecord $owner */
        $owner = $this->owner;
        return (new Query)
            ->select([
                'value' => "CASE action_type "
                    . "WHEN 'INSERT' THEN jsonb_object_field_text(row_data, :attribute::text) "
                    . "ELSE jsonb_object_field_text(changed_fields, :attribute::text) END",
                'action_id',
            ])
            ->from($this->auditTableName)
            ->where(['AND',
                'relation_id = \''.$owner->tableName().'\'::regclass',
                'statement_only = false',
                ['OR',
                    ['AND', 'action_type = \'INSERT\'', "jsonb_exists(row_data, :attribute)"],
                    ['AND', 'action_type = \'UPDATE\'', "jsonb_exists(changed_fields, :attribute)"],
                ],
                'row_data @> :primaryKey',
            ], [
                //':tableName' => $owner->tableName(),
                ':attribute' => $attribute,
                ':primaryKey' => json_encode($owner->getPrimaryKey(true)),
            ])
            ->orderBy('action_id')
            ->indexBy('action_id')
            ->column($owner->getDb());
    }
public function getAttributeVersions ( $ attribute ) { /** @var ActiveRecord $owner */ $ owner = $ this -> owner ; return ( new Query ) -> select ( [ 'value' => "CASE action_type " . "WHEN 'INSERT' THEN jsonb_object_field_text(row_data, :attribute::text) " . "ELSE jsonb_object_field_text(changed_fields, :attribute::text) END" , 'action_id' , ] ) -> from ( $ this -> auditTableName ) -> where ( [ 'AND' , 'relation_id = \'' . $ owner -> tableName ( ) . '\'::regclass' , 'statement_only = false' , [ 'OR' , [ 'AND' , 'action_type = \'INSERT\'' , "jsonb_exists(row_data, :attribute)" ] , [ 'AND' , 'action_type = \'UPDATE\'' , "jsonb_exists(changed_fields, :attribute)" ] , ] , 'row_data @> :primaryKey' , ] , [ //':tableName' => $owner->tableName(), ':attribute' => $ attribute , ':primaryKey' => json_encode ( $ owner -> getPrimaryKey ( true ) ) , ] ) -> orderBy ( 'action_id' ) -> indexBy ( 'action_id' ) -> column ( $ owner -> getDb ( ) ) ; }
Returns all recorded values for specified attribute.
@param string $attribute attribute name
@return array attribute values indexed by version id
Returns all recorded values for specified attribute .