public static function doDelete(Criteria $criteria, PropelPDO $con)
    {
        $db = Propel::getDB($criteria->getDbName());
        $dbMap = Propel::getDatabaseMap($criteria->getDbName());

        //join are not supported with DELETE statement
        if (count($criteria->getJoins())) {
            throw new PropelException('Delete does not support join');
        }

        // Set up a list of required tables (one DELETE statement will
        // be executed per table)
        $tables = $criteria->getTablesColumns();
        if (empty($tables)) {
            throw new PropelException("Cannot delete from an empty Criteria");
        }

        $affectedRows = 0; // initialize this in case the next loop has no iterations.

        foreach ($tables as $tableName => $columns) {

            $whereClause = array();
            $params = array();
            $stmt = null;
            try {
                $sql = $db->getDeleteFromClause($criteria, $tableName);

                foreach ($columns as $colName) {
                    $sb = "";
                    $criteria->getCriterion($colName)->appendPsTo($sb, $params);
                    $whereClause[] = $sb;
                }
                $sql .= " WHERE " . implode(" AND ", $whereClause);

                $stmt = $con->prepare($sql);
                $db->bindValues($stmt, $params, $dbMap);
                $stmt->execute();
                $affectedRows = $stmt->rowCount();
            } catch (Exception $e) {
                Propel::log($e->getMessage(), Propel::LOG_ERR);
                throw new PropelException(sprintf('Unable to execute DELETE statement [%s]', $sql), $e);
            }
        } // for each table

        return $affectedRows;
    }
public static function doDelete(Criteria $criteria, PropelPDO $con)
    {
        $db = Propel::getDB($criteria->getDbName());
        $dbMap = Propel::getDatabaseMap($criteria->getDbName());

        //join are not supported with DELETE statement
        if (count($criteria->getJoins())) {
            throw new PropelException('Delete does not support join');
        }

        // Set up a list of required tables (one DELETE statement will
        // be executed per table)
        $tables = $criteria->getTablesColumns();
        if (empty($tables)) {
            throw new PropelException("Cannot delete from an empty Criteria");
        }

        $affectedRows = 0; // initialize this in case the next loop has no iterations.

        foreach ($tables as $tableName => $columns) {

            $whereClause = array();
            $params = array();
            $stmt = null;
            try {
                $sql = $db->getDeleteFromClause($criteria, $tableName);

                foreach ($columns as $colName) {
                    $sb = "";
                    $criteria->getCriterion($colName)->appendPsTo($sb, $params);
                    $whereClause[] = $sb;
                }
                $sql .= " WHERE " . implode(" AND ", $whereClause);

                $stmt = $con->prepare($sql);
                $db->bindValues($stmt, $params, $dbMap);
                $stmt->execute();
                $affectedRows = $stmt->rowCount();
            } catch (Exception $e) {
                Propel::log($e->getMessage(), Propel::LOG_ERR);
                throw new PropelException(sprintf('Unable to execute DELETE statement [%s]', $sql), $e);
            }
        } // for each table

        return $affectedRows;
    }
public static function doDelete ( Criteria $ criteria , PropelPDO $ con ) { $ db = Propel :: getDB ( $ criteria -> getDbName ( ) ) ; $ dbMap = Propel :: getDatabaseMap ( $ criteria -> getDbName ( ) ) ; //join are not supported with DELETE statement if ( count ( $ criteria -> getJoins ( ) ) ) { throw new PropelException ( 'Delete does not support join' ) ; } // Set up a list of required tables (one DELETE statement will // be executed per table) $ tables = $ criteria -> getTablesColumns ( ) ; if ( empty ( $ tables ) ) { throw new PropelException ( "Cannot delete from an empty Criteria" ) ; } $ affectedRows = 0 ; // initialize this in case the next loop has no iterations. foreach ( $ tables as $ tableName => $ columns ) { $ whereClause = array ( ) ; $ params = array ( ) ; $ stmt = null ; try { $ sql = $ db -> getDeleteFromClause ( $ criteria , $ tableName ) ; foreach ( $ columns as $ colName ) { $ sb = "" ; $ criteria -> getCriterion ( $ colName ) -> appendPsTo ( $ sb , $ params ) ; $ whereClause [ ] = $ sb ; } $ sql .= " WHERE " . implode ( " AND " , $ whereClause ) ; $ stmt = $ con -> prepare ( $ sql ) ; $ db -> bindValues ( $ stmt , $ params , $ dbMap ) ; $ stmt -> execute ( ) ; $ affectedRows = $ stmt -> rowCount ( ) ; } catch ( Exception $ e ) { Propel :: log ( $ e -> getMessage ( ) , Propel :: LOG_ERR ) ; throw new PropelException ( sprintf ( 'Unable to execute DELETE statement [%s]' , $ sql ) , $ e ) ; } } // for each table return $ affectedRows ; }
Method to perform deletes based on values and keys in a
Criteria.

@param Criteria  $criteria The criteria to use.
@param PropelPDO $con      A PropelPDO connection object.

@return int The number of rows affected by last statement execution.  For most
uses there is only one delete statement executed, so this number
will correspond to the number of rows affected by the call to this
method.  Note that the return value does require that this information
is returned (supported) by the PDO driver.
@throws PropelException
Method to perform deletes based on values and keys in a Criteria .