Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function generatestring($length = 8)
- {
- $chars = 'abdefhiknrstyzABDEFGHKNQRSTYZ23456789';
- $numChars = strlen($chars);
- $string = '';
- for ($i = 0; $i < $length; $i++) {
- $string .= substr($chars, rand(1, $numChars) - 1, 1);
- }
- return $string;
- }
- $user = 'root';
- $pass = 'root';
- $dbh = new PDO('mysql:host=localhost;dbname=test_innodb', $user, $pass);
- for ($i = 1; $i <= 1000000000; $i++) {
- if ($i % 1000 == 0) {
- echo "\t== Старт == \nЗапрос $i\n";
- }
- $varchar = generatestring(255);
- $bigint = mt_rand(10000000, 1000000000);
- $text = generatestring(9999);
- $longtext = generatestring(9999);
- $statement = $dbh->prepare("INSERT INTO tableForTest(`varchar`, `bigint`, `text`, `longtext`) VALUES('$varchar', '$bigint', '$text', '$longtext')");
- $statement->execute();
- if ($i % 15000 == 0) {
- echo "Очистка $i\n";
- $dbh->exec("DELETE FROM tableForTest WHERE `bigint` % 3 = 1");
- }
- if ($i % 10000 == 0) {
- echo "Очистка $i\n";
- $dbh->exec("DELETE FROM tableForTest WHERE `bigint` % 4 = 0");
- }
- if ($i % 54321 == 0) {
- echo "Очистка $i\n";
- $dbh->exec("DELETE FROM tableForTest WHERE `bigint` != 0");
- }
- if ($i % 1000 == 0) {
- echo "\t== Конец == \n\n";
- }
- }
- echo "Финал\n";
- $dbh->exec("DELETE FROM tableForTest WHERE `bigint` != 0");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement