PHP Classes

File: example.php

Recommend this page to a friend!
  Classes of Rafael Jaques   DB Populator   example.php   Download  
File: example.php
Role: Example script
Content type: text/plain
Description: Example of usage
Class: DB Populator
Populate a MySQL database with random data
Author: By
Last change: Accessible without user login.
Date: 14 years ago
Size: 645 bytes
 

Contents

Class file image Download
<?php

   
require('dbpopulator.class.php');
   
   
$db = new DBPopulator();
   
   
$db->setDb('localhost', 'root', 'root');
   
   
// You can either use 'database.table' or 'database.*'
   
$db->populate('mydb.mytable');
   
$db->populate('mydb.*');
   
   
// And you can also use any combination of these methods, using an array
   
$db->populate(array('mydb.table', 'another_db.*'));
   
   
// It's possible to define the number of inserted data
   
$db->populate('mydb.mytable', 20);
   
   
// And you can generate a file with the insert statements
   
$db->populate('mydb.mytable', NULL, 'dummy_inserts.sql');