Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- DEFINE ('DB_USER', 'root'); //username
- DEFINE ('DB_PASSWORD', 'password'); //password
- DEFINE ('DB_HOST', 'localhost'); //IP/localhost
- DEFINE ('DB_NAME', 'dbname'); //database name
- $dbc = new mysqli(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
- $ctarray = array();
- $vsebinaarray = array();
- //število ustvarjenih tabel
- $st_tabel = 100;
- //število stolpcev na tabelo
- $st_stolpcev = 50;
- //šrevilo vrstic
- $st_vrstic = 1000000;
- //STEVILO STOLPCEV st0 varchar(255)...
- for($i = 0; $i <= $st_stolpcev; $i++){
- $ctarray[] = "st$i";
- }
- //doda podatkovni tip stolpcu
- $str = implode(" varchar(255), ", $ctarray);
- $str = $str . ' varchar(255)';
- //st0, st1, st2 za INSERT INTO
- $elementi = implode(", ", $ctarray);
- //stevilo ustvarjenih tabel
- for($l = 0; $l <= $st_tabel; $l++){
- //CREATE TABLE tab0 (id int auto_increment not null primary key, st0 varchar(255), st1 varchar(255), st2 varchar(255))
- $query_create = "CREATE TABLE tab$l (id int auto_increment not null primary key, $str)";
- $res_insert = mysqli_query($dbc, $query_create);
- //stevilo vrstic, ki jih ustvari (1000000)
- for($k = 0; $k < $st_vrstic; $k++){
- //stevilo stolpcev (naredi podatke)
- for($i = 0; $i <= $st_stolpcev; $i++){
- //izracuna 64 znakov dolgi hash (varchar sprejme 255)
- $el = '"' . hash("sha256", rand(1, 1000000)) . '"';
- $vsebinaarray[] = $el;
- }
- //doda vejice k hashu ( hash, hash, )
- $vsebina = implode(", ", $vsebinaarray);
- //INSERT INTO tab0 (st0, st1, st3) VALUES ("956707df478593e", "d2b0171b504250f0", "b3ce289cc11bda899e")
- $insert = "INSERT INTO tab$l ($elementi) VALUES ($vsebina)";
- $res1_insert = mysqli_query($dbc, $insert);
- //pobriše array
- unset($vsebinaarray);
- $vsebina = "";
- $insert = "";
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement