src/xPDO/xPDO.php
public function removeObject($className, $criteria) {
        $removed= false;
        if ($this->getConnection(array(xPDO::OPT_CONN_MUTABLE => true))) {
            if ($this->getCount($className, $criteria) === 1) {
                if ($query= $this->newQuery($className)) {
                    $query->command('DELETE');
                    $query->where($criteria);
                    if ($query->prepare()) {
                        if ($this->exec($query->toSQL()) !== 1) {
                            $this->log(xPDO::LOG_LEVEL_ERROR, "xPDO->removeObject - Error deleting {$className} instance using query " . $query->toSQL());
                        } else {
                            $removed= true;
                            if ($this->getOption(xPDO::OPT_CACHE_DB)) {
                                $this->cacheManager->delete(Cache\xPDOCacheManager::CACHE_DIR . $query->getAlias(), array('multiple_object_delete' => true));
                            }
                            $callback = $this->getOption(xPDO::OPT_CALLBACK_ON_REMOVE);
                            if ($callback && is_callable($callback)) {
                                call_user_func($callback, array('className' => $className, 'criteria' => $query));
                            }
                        }
                    }
                }
            } else {
                $this->log(xPDO::LOG_LEVEL_WARN, "xPDO->removeObject - {$className} instance to remove not found!");
                if ($this->getDebug() === true) $this->log(xPDO::LOG_LEVEL_DEBUG, "xPDO->removeObject - {$className} instance to remove not found using criteria " . print_r($criteria, true));
            }
        } else {
            $this->log(xPDO::LOG_LEVEL_ERROR, "Could not get connection for writing data", '', __METHOD__, __FILE__, __LINE__);
        }
        return $removed;
    }
public function removeObject($className, $criteria) {
        $removed= false;
        if ($this->getConnection(array(xPDO::OPT_CONN_MUTABLE => true))) {
            if ($this->getCount($className, $criteria) === 1) {
                if ($query= $this->newQuery($className)) {
                    $query->command('DELETE');
                    $query->where($criteria);
                    if ($query->prepare()) {
                        if ($this->exec($query->toSQL()) !== 1) {
                            $this->log(xPDO::LOG_LEVEL_ERROR, "xPDO->removeObject - Error deleting {$className} instance using query " . $query->toSQL());
                        } else {
                            $removed= true;
                            if ($this->getOption(xPDO::OPT_CACHE_DB)) {
                                $this->cacheManager->delete(Cache\xPDOCacheManager::CACHE_DIR . $query->getAlias(), array('multiple_object_delete' => true));
                            }
                            $callback = $this->getOption(xPDO::OPT_CALLBACK_ON_REMOVE);
                            if ($callback && is_callable($callback)) {
                                call_user_func($callback, array('className' => $className, 'criteria' => $query));
                            }
                        }
                    }
                }
            } else {
                $this->log(xPDO::LOG_LEVEL_WARN, "xPDO->removeObject - {$className} instance to remove not found!");
                if ($this->getDebug() === true) $this->log(xPDO::LOG_LEVEL_DEBUG, "xPDO->removeObject - {$className} instance to remove not found using criteria " . print_r($criteria, true));
            }
        } else {
            $this->log(xPDO::LOG_LEVEL_ERROR, "Could not get connection for writing data", '', __METHOD__, __FILE__, __LINE__);
        }
        return $removed;
    }
public function removeObject ( $ className , $ criteria ) { $ removed = false ; if ( $ this -> getConnection ( array ( xPDO :: OPT_CONN_MUTABLE => true ) ) ) { if ( $ this -> getCount ( $ className , $ criteria ) === 1 ) { if ( $ query = $ this -> newQuery ( $ className ) ) { $ query -> command ( 'DELETE' ) ; $ query -> where ( $ criteria ) ; if ( $ query -> prepare ( ) ) { if ( $ this -> exec ( $ query -> toSQL ( ) ) !== 1 ) { $ this -> log ( xPDO :: LOG_LEVEL_ERROR , "xPDO->removeObject - Error deleting {$className} instance using query " . $ query -> toSQL ( ) ) ; } else { $ removed = true ; if ( $ this -> getOption ( xPDO :: OPT_CACHE_DB ) ) { $ this -> cacheManager -> delete ( Cache \ xPDOCacheManager :: CACHE_DIR . $ query -> getAlias ( ) , array ( 'multiple_object_delete' => true ) ) ; } $ callback = $ this -> getOption ( xPDO :: OPT_CALLBACK_ON_REMOVE ) ; if ( $ callback && is_callable ( $ callback ) ) { call_user_func ( $ callback , array ( 'className' => $ className , 'criteria' => $ query ) ) ; } } } } } else { $ this -> log ( xPDO :: LOG_LEVEL_WARN , "xPDO->removeObject - {$className} instance to remove not found!" ) ; if ( $ this -> getDebug ( ) === true ) $ this -> log ( xPDO :: LOG_LEVEL_DEBUG , "xPDO->removeObject - {$className} instance to remove not found using criteria " . print_r ( $ criteria , true ) ) ; } } else { $ this -> log ( xPDO :: LOG_LEVEL_ERROR , "Could not get connection for writing data" , '' , __METHOD__ , __FILE__ , __LINE__ ) ; } return $ removed ; }
Remove an instance of the specified className by a supplied criteria.

@param string $className The name of the class to remove an instance of.
@param mixed $criteria Valid xPDO criteria for selecting an instance.
@return boolean True if the instance is successfully removed.
Remove an instance of the specified className by a supplied criteria .