public function bulkInsertRecords($tablename, $parameters, $limit = 25)
    {
        if(empty($parameters))
            throw new DatabaseException('bulkInsertRecords: no parameters.');

        $count      = 0;
        $tcount     = 0;
        $totalcount = count($parameters);

        foreach ($parameters as $value) {

            if (!is_array($value))
                throw new DatabaseException('bulkInsertRecords requires an array of arrays');

            if ($count == 0) {
                $sql = "INSERT INTO  ".$tablename." ";
                $sql .= " (".implode(",", array_keys($value)).")\n VALUES\n ";
                $first = false;
            }

            $sql .= "(".implode(",", array_map(array($this, 'quote'), (array)$value))."),\n";

            ++$count;
            ++$tcount;

            if ($count == $limit || $tcount == $totalcount) {
                $sql = substr($sql, 0, -2);
                $this->write($sql);
                $count = 0;
            }
        }
    }