1: <?php
2: class GnEscuela
3: {
4:
5: function __construct($bd=null)
6: {
7: if(empty($bd)){
8: require_once('../core/incluir.php');
9: $nivel_dir = 3;
10: $libs = new Incluir($nivel_dir);
11: $this->bd = $libs->incluir('db');
12: }
13: $this->bd = (!empty($bd)) ? $bd : $this->bd;
14: }
15:
16: 17: 18: 19: 20:
21: public function listar_escuela($filtros=null, $campos=' * ')
22: {
23: $respuesta = array();
24: $query = "select ".$campos." from gn_escuela ";
25: $stmt = $this->bd->ejecutar($query);
26: while ($escuela = $this->bd->obtener_fila($stmt, 0)) {
27: array_push($respuesta, $escuela);
28: }
29: return $respuesta;
30: }
31:
32: 33: 34: 35: 36: 37:
38: public function abrir_escuela(Array $filtros, $campos='*')
39: {
40: if(is_array($filtros)){
41: $condicion = ' where gn_escuela._id>0 ';
42: foreach ($filtros as $key => $filtro) {
43: $condicion .= ' and '.$key.'="'.$filtro.'" ';
44: }
45: }
46: $query = "select ".$campos." from gn_escuela ".$condicion;
47: $stmt = $this->bd->ejecutar($query);
48: if ($escuela = $this->bd->obtener_fila($stmt, 0)) {
49: return $escuela;
50: }
51: else{
52: return false;
53: }
54: }
55:
56: }
57: ?>