library/Garp/Content/Import/Abstract.php
public function rollback(Garp_Model $model, array $primaryKeys) {
        if (empty($primaryKeys)) {
            return;
        }
        $primaryCols = (array)$model->info(Zend_Db_Table::PRIMARY);
        $where = array();
        foreach ($primaryKeys as $pk) {
            $recordWhere = array();
            foreach ((array)$pk as $i => $key) {
                $recordWhere[] = $model->getAdapter()->quoteIdentifier(current($primaryCols)).' = '.
                                 $model->getAdapter()->quote($key);
            }
            $recordWhere = implode(' AND ', $recordWhere);
            $recordWhere = '('.$recordWhere.')';
            $where[] = $recordWhere;
            reset($primaryCols);
        }
        $where = implode(' OR ', $where);
        if (empty($where)) {
            return;
        }
        $model->delete($where);
    }
public function rollback(Garp_Model $model, array $primaryKeys) {
        if (empty($primaryKeys)) {
            return;
        }
        $primaryCols = (array)$model->info(Zend_Db_Table::PRIMARY);
        $where = array();
        foreach ($primaryKeys as $pk) {
            $recordWhere = array();
            foreach ((array)$pk as $i => $key) {
                $recordWhere[] = $model->getAdapter()->quoteIdentifier(current($primaryCols)).' = '.
                                 $model->getAdapter()->quote($key);
            }
            $recordWhere = implode(' AND ', $recordWhere);
            $recordWhere = '('.$recordWhere.')';
            $where[] = $recordWhere;
            reset($primaryCols);
        }
        $where = implode(' OR ', $where);
        if (empty($where)) {
            return;
        }
        $model->delete($where);
    }
public function rollback ( Garp_Model $ model , array $ primaryKeys ) { if ( empty ( $ primaryKeys ) ) { return ; } $ primaryCols = ( array ) $ model -> info ( Zend_Db_Table :: PRIMARY ) ; $ where = array ( ) ; foreach ( $ primaryKeys as $ pk ) { $ recordWhere = array ( ) ; foreach ( ( array ) $ pk as $ i => $ key ) { $ recordWhere [ ] = $ model -> getAdapter ( ) -> quoteIdentifier ( current ( $ primaryCols ) ) . ' = ' . $ model -> getAdapter ( ) -> quote ( $ key ) ; } $ recordWhere = implode ( ' AND ' , $ recordWhere ) ; $ recordWhere = '(' . $ recordWhere . ')' ; $ where [ ] = $ recordWhere ; reset ( $ primaryCols ) ; } $ where = implode ( ' OR ' , $ where ) ; if ( empty ( $ where ) ) { return ; } $ model -> delete ( $ where ) ; }
Rollback all inserts when the import throws an error halfway
@param Garp_Model $model
@param Array $primaryKeys Collection of primary keys
@return Void
Rollback all inserts when the import throws an error halfway