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

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

Query specs for DELETE operations
public addDeleteQuerySpecs ( stdClass $row ) : void
$row stdClass Data row
Результат void
    public function addDeleteQuerySpecs(\stdClass $row)
    {
        $dbprefix = elgg_get_config('dbprefix');
        $sql = "\n\t\t\tDELETE FROM {$dbprefix}entities\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])) {
                // Query spec will be cleared after row is deleted from objects table
                unset($this->rows[$row->guid]);
                return [$row->guid];
            }
            return [];
        }, 'times' => 1]);
        // Entity might not have any relationships, therefore adding the spec here
        // and not in the relationships table mock
        // @todo: figure out a way to remove this from relationships table
        foreach (['guid_one', 'guid_two'] as $column) {
            $sql = "DELETE er FROM {$dbprefix}entity_relationships AS er\n\t\t\t\tWHERE {$column} = {$row->guid}";
            $this->query_specs[$row->guid][] = $this->db->addQuerySpec(['sql' => $sql, 'row_count' => 0, 'times' => 1]);
        }
        // Private settings cleanup
        $sql = "\n\t\t\tDELETE FROM {$dbprefix}private_settings\n\t\t\tWHERE entity_guid = {$row->guid}\n\t\t";
        $this->query_specs[$row->guid][] = $this->db->addQuerySpec(['sql' => $sql, 'row_count' => 0, 'times' => 1]);
        // River table clean up
        foreach (['subject_guid', 'object_guid', 'target_guid'] as $column) {
            $sql = "DELETE rv.* FROM {$dbprefix}river rv  WHERE (rv.{$column} IN ({$row->guid})) AND 1=1";
            $this->query_specs[$row->guid][] = $this->db->addQuerySpec(['sql' => $sql, 'row_count' => 0, 'times' => 1]);
        }
        // Objects table clean up
        // @todo: move this into an object table mock once it's in
        $sql = "\n\t\t\tDELETE FROM {$dbprefix}objects_entity\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])) {
                unset($this->rows[$row->guid]);
                unset($this->mocks[$row->guid]);
                $this->clearQuerySpecs($row->guid);
                return [$row->guid];
            }
            return [];
        }, 'times' => 1]);
    }