Elgg\Mocks\Database\PrivateSettingsTable::addQuerySpecs PHP Метод

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

Add query query_specs for a metadata object
public addQuerySpecs ( stdClass $row ) : void
$row stdClass Data row
Результат void
    public function addQuerySpecs(stdClass $row)
    {
        $this->clearQuerySpecs($row);
        // Set a new setting
        $query = "\n\t\t\tINSERT into {$this->table}\n\t\t\t(entity_guid, name, value) VALUES\n\t\t\t(:entity_guid, :name, :value)\n\t\t\tON DUPLICATE KEY UPDATE value = :value\n\t\t";
        $params = [':entity_guid' => (int) $row->entity_guid, ':name' => (string) $row->name, ':value' => (string) $row->value];
        $this->query_specs[$row->id][] = $this->db->addQuerySpec(['sql' => $query, 'params' => $params, 'insert_id' => $row->id]);
        // Get setting by its value
        $query = "\n\t\t\tSELECT value FROM {$this->table}\n\t\t\tWHERE name = :name\n\t\t\tAND entity_guid = :entity_guid\n\t\t";
        $params = [':entity_guid' => (int) $row->entity_guid, ':name' => (string) $row->name];
        $this->query_specs[$row->id][] = $this->db->addQuerySpec(['sql' => $query, 'params' => $params, 'results' => function () use($row) {
            if (isset($this->rows[$row->id])) {
                return [$this->rows[$row->id]];
            }
            return [];
        }]);
        $query = "\n\t\t\tDELETE FROM {$this->table}\n\t\t\tWHERE name = :name\n\t\t\tAND entity_guid = :entity_guid\n\t\t";
        $params = [':entity_guid' => (int) $row->entity_guid, ':name' => (string) $row->name];
        $this->query_specs[$row->id][] = $this->db->addQuerySpec(['sql' => $query, 'params' => $params, 'results' => function () use($row) {
            if (isset($this->rows[$row->id])) {
                unset($this->rows[$row->id]);
                $this->clearQuerySpecs($row);
                return [$row->id];
            }
            return [];
        }]);
    }