删除数据
DELETE QUERY

@return int 返回影响的行数,
970683
public function delete() {
        $query = $this->getPrimaryKeyQuery();
        if (empty($query)) {
            return false;
        }
        $row = $query->delete();
        if (!empty($row)) {
            $this->initOldAttribute();
        }
        return $row;
    }
524334
public function delete(): int
    {
        $deleted = $this->createDeleteBuilder()->execute();

        $this->clearFetchParameters();

        return (int)$deleted;
    }
1140683
public function delete() : int
    {
        $table = $this->definition->getName();
        $sql = 'DELETE FROM '.$table.' ';
        $par = [];
        if (count($this->where)) {
            $sql .= 'WHERE ';
            $tmp = [];
            foreach ($this->where as $v) {
                $tmp[] = $v[0];
                $par = array_merge($par, $v[1]);
            }
            $sql .= implode(' AND ', $tmp) . ' ';
        }
        if (count($this->order)) {
            $sql .= $this->order[0];
            $par = array_merge($par, $this->order[1]);
        }
        return $this->db->query($sql, $par)->affected();
    }
265907
public function delete(Query $query)
    {
        // 分析查询表达式
        $options = $query->getOptions();
        $pk      = $query->getPk($options);
        $data    = $options['data'];

        if (!is_null($data) && true !== $data) {
            if (!is_array($data)) {
                // 缓存标识
                $key = 'mongo:' . $options['table'] . '|' . $data;
            }

            // AR模式分析主键条件
            $query->parsePkWhere($data);
        } elseif (!isset($key) && is_string($pk) && isset($options['where']['$and'][$pk])) {
            $key = $this->getCacheKey($options['where']['$and'][$pk], $options);
        }

        if (true !== $data && empty($options['where'])) {
            // 如果不是强制删除且条件为空 不进行删除操作
            throw new Exception('delete without condition');
        }

        // 生成bulkWrite对象
        $bulk = $this->builder->delete($query);

        $writeConcern = isset($options['writeConcern']) ? $options['writeConcern'] : null;

        // 执行操作
        $writeResult = $this->execute($options['table'], $bulk, $writeConcern);

        // 检测缓存
        if ($this->cache && isset($key) && $this->cache->get($key)) {
            // 删除缓存
            $this->cache->rm($key);
        }

        $result = $writeResult->getDeletedCount();

        if ($result) {
            if (!is_array($data) && is_string($pk) && isset($key) && strpos($key, '|')) {
                list($a, $val) = explode('|', $key);

                $item[$pk] = $val;
                $data      = $item;
            }

            $query->setOption('data', $data);
            $query->trigger('after_delete');
        }
        return $result;
    }
173571
public function deleteAll()
    {
        $this->query->type = QueryType::$DELETE;
        return QueryExecutor::prepare($this->db, $this->query)->execute();
    }
188143
public function delete(): IResult
    {
        $query = static::query($this);
        $query = $this->parseWhereId($query);

        // 删除前
        $this->trigger(ModelEvents::BEFORE_DELETE, [
            'model' => $this,
            'query' => $query,
        ], $this, \Imi\Model\Event\Param\BeforeDeleteEventParam::class);

        if(!isset($query->getOption()->where[0]))
        {
            throw new \RuntimeException('use Model->delete(), primary key can not be null');
        }
        $result = $query->delete();

        // 删除后
        $this->trigger(ModelEvents::AFTER_DELETE, [
            'model' => $this,
            'result'=> $result,
        ], $this, \Imi\Model\Event\Param\AfterDeleteEventParam::class);

        // 子模型删除
        ModelRelationManager::deleteModel($this);

        return $result;
    }
667260
public static function delete()
    {
        $result = null;

        switch (static::getDriver()) {
            case self::DRIVER_MYSQL:
                $result = new \pwf\components\querybuilder\adapters\MySQL\DeleteBuilder();
                break;
            case self::DRIVER_PG:
                $result = new \pwf\components\querybuilder\adapters\PostgreSQL\DeleteBuilder();
                break;
            default:
                throw new \Exception('Wrong query builder driver');
        }

        return $result;
    }
109025
public int deleteAll() throws SQLException {

		int count = 0;

		if (isTableExists()) {
			DeleteBuilder<TableIndex, String> db = deleteBuilder();
			PreparedDelete<TableIndex> deleteQuery = db.prepare();
			count = delete(deleteQuery);
		}

		return count;
	}
1034443
public function delete(): int
    {
        $pdoStatement = $this->provideStatement();
        $pdoStatement = $this->execute($pdoStatement);
        return $pdoStatement->rowCount();
    }
337071
public function delete()
    {
        $where = $this->_getWhereQuery();

        /**
         * Execute the DELETE (this may throw an exception)
         */
        $result = $this->_getTable()->delete($where);

        /**
         * Reset all fields to null to indicate that the row is not there
         */
        $this->_data = array_combine(
            array_keys($this->_data),
            array_fill(0, count($this->_data), null)
        );

        return $result;
    }
325791
public function delete()
    {
        $primary_key_value = $this->getKeyValue();

        $builder = static::query();

        if ($primary_key_value == null) {
            return 0;
        }

        if (!$builder->exists($this->primary_key, $primary_key_value)) {
            return 0;
        }

        $r = $builder
            ->where($this->primary_key, $primary_key_value)
            ->delete();

        if ($r == 1) {
            $this->fireEvent('ondeleted');
        }

        return $r;
    }
673818
public function delete()
    {
        $affected = 0;
        foreach ($this->table->data['data'] as $rs) {
            if ($this->matchWhere($rs)) {
                unset($this->table->data['data'][$rs['id']]);
                $affected++;
            }
        }

        if ($affected) {
            $this->table->save();
        }

        return $affected;
    }
1287402
public function delete()
    {
        $db = $this->getConnection();
        return $db->delete(
            $this->getDatabase() . urlencode( $this->_id ) . '?rev=' . $this->_rev
        ); 
    }
965282
public function delete()
    {
        $query = "DELETE FROM `{$this->table}` {$this->join}";
        if ($this->condition) {
            $query .= " WHERE {$this->condition}";
        }
        if ($this->limit) {
            $query .= " LIMIT {$this->limit}";
        }

        return $this->connection->execQuery($query, $this->params);
    }
331134
public function delete()
    {
        $query = sprintf(
            "DELETE FROM `{$this->table}` WHERE `%s` = %s",
            $this->primary,
            $this->adapter->getDriver()->quote($this->uid, $this->properties[$this->primary]['type'])
        );

        $statement = $this->adapter->getDriver()->query($query);

        if ($statement->rowsAffected() === 0) {
            throw new Exception('Failed to delete entity "' . CamelCase::to($this->table) . ' #' . $this->uid . '"');
        }

        $this->modified = null;
        $this->uid = null;
    }
619487
public function delete()
    {
        $ret = $this->conn()->selectCollection($this->table_name)->remove($this->where);
        $this->sql = array('table'=> $this->table_name,'where'=>$this->where);

        $this->_clear_var();
        return $ret;
    }
683976
public function delete()
    {
        if ($this->getCacheBusting()) {
            $this->queryCache()->flush($this->getTable());
        }

        return parent::delete();
    }