public static function deleteAllRows($table, $where, $orderBy, $maxRowsPerQuery = 100000, $parameters = array())
    {
        $orderByClause = $orderBy ? "ORDER BY $orderBy" : "";

        $sql = "DELETE FROM $table $where $orderByClause
                LIMIT " . (int)$maxRowsPerQuery;

        // delete rows w/ a limit
        $totalRowsDeleted = 0;

        do {
            $rowsDeleted = self::query($sql, $parameters)->rowCount();

            $totalRowsDeleted += $rowsDeleted;
        } while ($rowsDeleted >= $maxRowsPerQuery);

        return $totalRowsDeleted;
    }
public static function deleteAllRows($table, $where, $orderBy, $maxRowsPerQuery = 100000, $parameters = array())
    {
        $orderByClause = $orderBy ? "ORDER BY $orderBy" : "";

        $sql = "DELETE FROM $table $where $orderByClause
                LIMIT " . (int)$maxRowsPerQuery;

        // delete rows w/ a limit
        $totalRowsDeleted = 0;

        do {
            $rowsDeleted = self::query($sql, $parameters)->rowCount();

            $totalRowsDeleted += $rowsDeleted;
        } while ($rowsDeleted >= $maxRowsPerQuery);

        return $totalRowsDeleted;
    }
public static function deleteAllRows ( $ table , $ where , $ orderBy , $ maxRowsPerQuery = 100000 , $ parameters = array ( ) ) { $ orderByClause = $ orderBy ? "ORDER BY $orderBy" : "" ; $ sql = "DELETE FROM $table $where $orderByClause
                LIMIT " . ( int ) $ maxRowsPerQuery ; // delete rows w/ a limit $ totalRowsDeleted = 0 ; do { $ rowsDeleted = self :: query ( $ sql , $ parameters ) -> rowCount ( ) ; $ totalRowsDeleted += $ rowsDeleted ; } while ( $ rowsDeleted >= $ maxRowsPerQuery ) ; return $ totalRowsDeleted ; }
Deletes all desired rows in a table, while using a limit. This function will execute many
DELETE queries until there are no more rows to delete.

Use this function when you need to delete many thousands of rows from a table without
locking the table for too long.

**Example**

// delete all visit rows whose ID is less than a certain value, 100000 rows at a time
$idVisit = // ...
Db::deleteAllRows(Common::prefixTable('log_visit'), "WHERE idvisit <= ?", "idvisit ASC", 100000, array($idVisit));

@param string $table The name of the table to delete from. Must be prefixed (see {@link Piwik\Common::prefixTable()}).
@param string $where The where clause of the query. Must include the WHERE keyword.
@param string $orderBy The column to order by and the order by direction, eg, `idvisit ASC`.
@param int $maxRowsPerQuery The maximum number of rows to delete per `DELETE` query.
@param array $parameters Parameters to bind for each query.
@return int The total number of rows deleted.
Deletes all desired rows in a table while using a limit . This function will execute many DELETE queries until there are no more rows to delete .