src/Charcoal/Source/DatabaseSource.php
public function deleteItem(StorableInterface $item = null)
    {
        if ($item !== null) {
            $this->setModel($item);
        }

        $model = $this->model();

        if (!$model->id()) {
            throw new UnexpectedValueException(
                sprintf('Can not delete "%s" item. No ID.', get_class($this))
            );
        }

        $key   = $model->key();
        $table = $this->table();
        $query = '
            DELETE FROM
                `'.$table.'`
            WHERE
                `'.$key.'` = :id';

        $driver = $this->db()->getAttribute(PDO::ATTR_DRIVER_NAME);
        if ($driver == self::MYSQL_DRIVER_NAME) {
            $query .= "\n".'LIMIT 1';
        }

        $binds = [
            'id' => $model->id()
        ];

        $result = $this->dbQuery($query, $binds);

        if ($result === false) {
            return false;
        } else {
            return true;
        }
    }
public function deleteItem(StorableInterface $item = null)
    {
        if ($item !== null) {
            $this->setModel($item);
        }

        $model = $this->model();

        if (!$model->id()) {
            throw new UnexpectedValueException(
                sprintf('Can not delete "%s" item. No ID.', get_class($this))
            );
        }

        $key   = $model->key();
        $table = $this->table();
        $query = '
            DELETE FROM
                `'.$table.'`
            WHERE
                `'.$key.'` = :id';

        $driver = $this->db()->getAttribute(PDO::ATTR_DRIVER_NAME);
        if ($driver == self::MYSQL_DRIVER_NAME) {
            $query .= "\n".'LIMIT 1';
        }

        $binds = [
            'id' => $model->id()
        ];

        $result = $this->dbQuery($query, $binds);

        if ($result === false) {
            return false;
        } else {
            return true;
        }
    }
public function deleteItem ( StorableInterface $ item = null ) { if ( $ item !== null ) { $ this -> setModel ( $ item ) ; } $ model = $ this -> model ( ) ; if ( ! $ model -> id ( ) ) { throw new UnexpectedValueException ( sprintf ( 'Can not delete "%s" item. No ID.' , get_class ( $ this ) ) ) ; } $ key = $ model -> key ( ) ; $ table = $ this -> table ( ) ; $ query = '
            DELETE FROM
                `' . $ table . '`
            WHERE
                `' . $ key . '` = :id' ; $ driver = $ this -> db ( ) -> getAttribute ( PDO :: ATTR_DRIVER_NAME ) ; if ( $ driver == self :: MYSQL_DRIVER_NAME ) { $ query .= "\n" . 'LIMIT 1' ; } $ binds = [ 'id' => $ model -> id ( ) ] ; $ result = $ this -> dbQuery ( $ query , $ binds ) ; if ( $ result === false ) { return false ; } else { return true ; } }
Delete an item from storage.

@param  StorableInterface $item Optional item to delete. If none, the current model object will be used.
@throws UnexpectedValueException If the item does not have an ID.
@return boolean TRUE if the item was deleted, otherwise FALSE.
Delete an item from storage .