public function delete($conditions)
    {
        if ($conditions instanceof \Traversable) {
            $conditions = iterator_to_array($conditions);
        } elseif (is_object($conditions)) {
            $conditions = get_object_vars($conditions);
        }

        if (!is_array($conditions)) {
            // Load by primary key.
            $keyCount = count($this->getKeyName(true));

            if ($keyCount) {
                if ($keyCount > 1) {
                    throw new \InvalidArgumentException(
                        'Table has multiple primary keys specified, only one primary key value provided.'
                    );
                }

                $conditions = [$this->getKeyName() => $conditions];
            } else {
                throw new \RuntimeException('No primary keys defined.');
            }
        }

        // Event
        $this->triggerEvent(
            'onBefore' . ucfirst(__FUNCTION__),
            [
                'conditions' => &$conditions,
            ]
        );

        $result = $this->doDelete($conditions);

        // Event
        $this->triggerEvent(
            'onAfter' . ucfirst(__FUNCTION__),
            [
                'result' => &$result,
            ]
        );

        return $result;
    }
public function delete($conditions)
    {
        if ($conditions instanceof \Traversable) {
            $conditions = iterator_to_array($conditions);
        } elseif (is_object($conditions)) {
            $conditions = get_object_vars($conditions);
        }

        if (!is_array($conditions)) {
            // Load by primary key.
            $keyCount = count($this->getKeyName(true));

            if ($keyCount) {
                if ($keyCount > 1) {
                    throw new \InvalidArgumentException(
                        'Table has multiple primary keys specified, only one primary key value provided.'
                    );
                }

                $conditions = [$this->getKeyName() => $conditions];
            } else {
                throw new \RuntimeException('No primary keys defined.');
            }
        }

        // Event
        $this->triggerEvent(
            'onBefore' . ucfirst(__FUNCTION__),
            [
                'conditions' => &$conditions,
            ]
        );

        $result = $this->doDelete($conditions);

        // Event
        $this->triggerEvent(
            'onAfter' . ucfirst(__FUNCTION__),
            [
                'result' => &$result,
            ]
        );

        return $result;
    }
public function delete ( $ conditions ) { if ( $ conditions instanceof \ Traversable ) { $ conditions = iterator_to_array ( $ conditions ) ; } elseif ( is_object ( $ conditions ) ) { $ conditions = get_object_vars ( $ conditions ) ; } if ( ! is_array ( $ conditions ) ) { // Load by primary key. $ keyCount = count ( $ this -> getKeyName ( true ) ) ; if ( $ keyCount ) { if ( $ keyCount > 1 ) { throw new \ InvalidArgumentException ( 'Table has multiple primary keys specified, only one primary key value provided.' ) ; } $ conditions = [ $ this -> getKeyName ( ) => $ conditions ] ; } else { throw new \ RuntimeException ( 'No primary keys defined.' ) ; } } // Event $ this -> triggerEvent ( 'onBefore' . ucfirst ( __FUNCTION__ ) , [ 'conditions' => & $ conditions , ] ) ; $ result = $ this -> doDelete ( $ conditions ) ; // Event $ this -> triggerEvent ( 'onAfter' . ucfirst ( __FUNCTION__ ) , [ 'result' => & $ result , ] ) ; return $ result ; }
Delete records by where conditions.

@param mixed $conditions   Where conditions, you can use array or Compare object.
Example:
- `array('id' => 5)` => id = 5
- `new GteCompare('id', 20)` => 'id >= 20'
- `new Compare('id', '%Flower%', 'LIKE')` => 'id LIKE "%Flower%"'

@return  boolean Will be always true.
Delete records by where conditions .