Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require __DIR__ . '/vendor/autoload.php';
- $dsn = 'mysql:dbname=db1;host=127.0.0.1';
- $user = 'root';
- $password = '(disensor)';
- try {
- $dbh = new PDO($dsn, $user, $password);
- $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
- } catch (PDOException $e) {
- echo 'Connection failed: ' . $e->getMessage();
- }
- $sth = $dbh->prepare('INSERT INTO category(category_name, category_description, category_enabled) VALUES(:category_name, :category_description, :category_enabled)');
- $faker = Faker\Factory::create();
- $faker->seed(time());
- for ($i = 1; $i <= 1000000; $i++) {
- $sth->bindValue('category_name', $faker->words(4, true) . " $i");
- $sth->bindValue('category_description', $faker->text() . " $i");
- $sth->bindValue('category_enabled', mt_rand(0, 1));
- $sth->execute();
- }
Add Comment
Please, Sign In to add comment