-
Notifications
You must be signed in to change notification settings - Fork 0
/
bd.php
69 lines (51 loc) · 1.78 KB
/
bd.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php
$servidor="localhost";
$baseDeDatos="lapolar";
$usuario="root";
$contrasena="";
try {
$conexion=new PDO("mysql:host=$servidor;dbname=$baseDeDatos",$usuario,$contrasena);
}catch(Exception $error){
echo $error->getMessage();
}
function obtenerMunicipiosEstados($conexion) {
$query = "SELECT * FROM municipios";
$stmt = $conexion->prepare($query);
$stmt->execute();
$municipios = $stmt->fetchAll(PDO::FETCH_ASSOC);
$query = "SELECT * FROM estados";
$stmt = $conexion->prepare($query);
$stmt->execute();
$estados = $stmt->fetchAll(PDO::FETCH_ASSOC);
$query = "SELECT * FROM colonias";
$stmt = $conexion->prepare($query);
$stmt->execute();
$colonias = $stmt->fetchAll(PDO::FETCH_ASSOC);
return array('municipios' => $municipios, 'estados' => $estados, 'colonias' => $colonias);
}
function obtenerMarcasModelos($conexion) {
$query = "SELECT * FROM marcas";
$stmt = $conexion->prepare($query);
$stmt->execute();
$marcas = $stmt->fetchAll(PDO::FETCH_ASSOC);
$query = "SELECT * FROM modelos";
$stmt = $conexion->prepare($query);
$stmt->execute();
$modelos = $stmt->fetchAll(PDO::FETCH_ASSOC);
return array('marcas' => $marcas, 'modelos' => $modelos);
}
function obtenerProveedores($conexion) {
$query = "SELECT * FROM proveedores";
$stmt = $conexion->prepare($query);
$stmt->execute();
$proveedores = $stmt->fetchAll(PDO::FETCH_ASSOC);
return array('proveedores' => $proveedores);
}
function obtenerEmpresa($conexion) {
$query = "SELECT * FROM clientes";
$stmt = $conexion->prepare($query);
$stmt->execute();
$clientes = $stmt->fetchAll(PDO::FETCH_ASSOC);
return array('clientes' => $clientes);
}
?>