Elgg\Mocks\Database\EntityTable::addUpdateQuerySpecs PHP Метод

addUpdateQuerySpecs() публичный Метод

Query specs for UPDATE operations
public addUpdateQuerySpecs ( stdClass $row ) : void
$row stdClass Data row
Результат void
    public function addUpdateQuerySpecs(stdClass $row)
    {
        $dbprefix = elgg_get_config('dbprefix');
        $sql = "\n\t\t\tUPDATE {$dbprefix}entities\n\t\t\tSET owner_guid = :owner_guid,\n\t\t\t\taccess_id = :access_id,\n\t\t\t\tcontainer_guid = :container_guid,\n\t\t\t\ttime_created = :time_created,\n\t\t\t\ttime_updated = :time_updated\n\t\t\tWHERE guid = :guid\n\t\t";
        $this->query_specs[$row->guid][] = $this->db->addQuerySpec(['sql' => $sql, 'params' => [':owner_guid' => $row->owner_guid, ':access_id' => $row->access_id, ':container_guid' => $row->container_guid, ':time_created' => $row->time_created, ':time_updated' => $row->time_updated, ':guid' => $row->guid], 'results' => function () use($row) {
            if (isset($this->rows[$row->guid])) {
                $this->rows[$row->guid] = $row;
                return [$row->guid];
            }
            return [];
        }]);
        // Disable
        $sql = "\n\t\t\tUPDATE {$dbprefix}entities\n\t\t\tSET enabled = 'no'\n\t\t\tWHERE guid = :guid\n\t\t";
        $this->query_specs[$row->guid][] = $this->db->addQuerySpec(['sql' => $sql, 'params' => [':guid' => $row->guid], 'results' => function () use($row) {
            if (isset($this->rows[$row->guid])) {
                $row->enabled = 'no';
                $this->rows[$row->guid] = $row;
                $this->addQuerySpecs($row);
                return [$row->guid];
            }
            return [];
        }, 'times' => 1]);
        // Enable
        $sql = "\n\t\t\tUPDATE {$dbprefix}entities\n\t\t\tSET enabled = 'yes'\n\t\t\tWHERE guid = :guid\n\t\t";
        $this->query_specs[$row->guid][] = $this->db->addQuerySpec(['sql' => $sql, 'params' => [':guid' => $row->guid], 'results' => function () use($row) {
            if (isset($this->rows[$row->guid])) {
                $row->enabled = 'yes';
                $this->rows[$row->guid] = $row;
                $this->addQuerySpecs($row);
                return [$row->guid];
            }
            return [];
        }, 'times' => 1]);
        // Update last action
        $time = $this->getCurrentTime()->getTimestamp();
        $sql = "\n\t\t\tUPDATE {$dbprefix}entities\n\t\t\tSET last_action = :last_action\n\t\t\tWHERE guid = :guid\n\t\t";
        $this->query_specs[$row->guid][] = $this->db->addQuerySpec(['sql' => $sql, 'params' => [':last_action' => $time, ':guid' => $row->guid], 'results' => function () use($row, $time) {
            if (isset($this->rows[$row->guid])) {
                $row->last_action = $time;
                $this->rows[$row->guid] = $row;
                $this->addQuerySpecs($row);
                return [$row->guid];
            }
            return [];
        }]);
        // Object table
        // @todo: this will need to be moved to the objects table mock once it's in
        if ($row->type == 'object') {
            $sql = "\n\t\t\t\tUPDATE {$dbprefix}objects_entity\n\t\t\t\tSET title = :title,\n\t\t\t\t\tdescription = :description\n\t\t\t\tWHERE guid = :guid\n\t\t\t";
            $this->query_specs[$row->guid][] = $this->db->addQuerySpec(['sql' => $sql, 'params' => [':guid' => $row->guid, ':title' => $row->title, ':description' => $row->description], 'results' => function () use($row) {
                if (isset($this->rows[$row->guid])) {
                    $this->rows[$row->guid] = $row;
                    return [$row->guid];
                }
                return [];
            }]);
        }
    }