Ejemplo n.º 1
0
<?php

require_once 'gestionBd.php';
require_once 'equipos.php';
$gestion = new GestionBd();
$equipo = new Equipo();
$sql = "create table equipos (\n equipos_id int(10) unsigned NOT NULL AUTO_INCREMENT,\n nombre varchar(50) NOT NULL,\n codigo varchar(50) NOT NULL,\n precio float(10,2) NOT NULL,\n fecha_fab date NOT NULL,\n fecha_in timestamp NOT NULL,\n garantia int(3) NOT NULL,\n PRIMARY KEY (equipos_id)\n );";
$gestion->borrarTabla("drop table equipos;");
$gestion->crearTabla($sql);
/*
 * Llenar BD con 5000 o más registros random
 */
for ($i = 0; $i < 6000; $i++) {
    $equipo->setNombre(ramdomNombre());
    $equipo->setCodigo(ramdomCodigo($equipo->getNombre()));
    $equipo->setPrecio(ramdomPrecio());
    $equipo->setFecha_fab(ramdomFechaFab());
    $equipo->setFecha_in(ramdomFechaIn());
    $equipo->setGarantia(ramdomGarantia());
    $gestion->insertarBd($equipo);
    echo " Ok";
}
?>