LazyRecord\BaseCollection::delete PHP Method

delete() public method

public delete ( )
    public function delete()
    {
        $schema = $this->getSchema();
        $dsId = $schema->getWriteSourceId();
        $conn = ConnectionManager::getInstance()->getConnection($dsId);
        $driver = $conn->createQueryDriver();
        $query = new DeleteQuery();
        $query->from($this->getTable());
        $query->setWhere(clone $this->getCurrentReadQuery()->getWhere());
        $arguments = new ArgumentArray();
        $sql = $query->toSql($driver, $arguments);
        try {
            $this->handle = $conn->prepareAndExecute($sql, $arguments->toArray());
        } catch (Exception $e) {
            return Result::failure('Collection delete failed: ' . $e->getMessage(), array('vars' => $arguments->toArray(), 'sql' => $sql, 'exception' => $e));
        }
        return Result::success('Deleted', array('sql' => $sql));
    }