· 7 years ago · Feb 06, 2019, 01:40 PM
1$create_db = $this->pdo->prepare('CREATE DATABASE IF NOT EXISTS '.$dataBaseName.' COLLATE utf8_general_ci');
2 $crear_db->execute();
3
4if($create_db):
5 $use_db = $this->pdo->prepare('USE '.$dataBaseName);
6 $use_db->execute();
7endif;
8
9$create_table = $this->pdo->prepare('
10 CREATE TABLE IF NOT EXISTS account_daily LIKE db_ref.account_daily;
11 CREATE TABLE IF NOT EXISTS account_plan LIKE db_ref.account_plan;
12 CREATE TABLE IF NOT EXISTS branch LIKE db_ref.branch;
13 CREATE TABLE IF NOT EXISTS cash_register LIKE db_ref.cash_register;
14 ');
15 $create_table->execute();
16
17//primera tabla
18$sql = "INSERT INTO account_plan (`acc_id`, `acc_number`, `acc_account`, `acc_class`, `acc_group`, `acc_active`, `acc_balance`) VALUES
19 (1, '1105', 'Caja', 'Activo', 'Activo - Disponible', 1, '0.00'),
20 //y asi otros registros
21 $insert_data = $this->pdo->prepare($sql);
22 $insert_data->execute();";
23
24//segunda tabla
25 $sql = "INSERT INTO type_grp (`typ_id`, `typ_active`, `typ_name`) VALUES
26 (1, 1, 'Inventario'),
27 (2, 1, 'Insumos'),
28 (3, 1, 'Servicios');";
29 $insert_data = $this->pdo->prepare($sql);
30 $insert_data->execute();
31
32//tercera tabla etc...