1: <?php
2: class GnClase
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: 22:
23: public function crear_clase($id_anno, $id_carrera, $id_grado)
24: {
25: $respuesta = array('msj' => 'no');
26: $query = "insert into gn_clase (id_anno, id_carrera, id_grado) values (".$id_anno.", ".$id_carrera.", ".$id_grado.")";
27: if ($this->bd->ejecutar($query)) {
28: $respuesta['msj'] = 'si';
29: $respuesta['_id'] = $this->bd->lastID();
30: }
31: return $respuesta;
32: }
33:
34: 35: 36: 37: 38: 39: 40:
41: public function buscar_clase($id_anno, $id_carrera, $id_grado)
42: {
43: $query = 'select * from gn_clase where id_anno='.$id_anno.' AND id_carrera='.$id_carrera.' AND id_grado='.$id_grado;
44: $stmt = $this->bd->ejecutar($query);
45: if ($clase = $this->bd->obtener_fila($stmt)) {
46: return $clase;
47: }
48: else{
49: return false;
50: }
51: }
52:
53: 54: 55: 56: 57: 58: 59:
60: public function abrir_clase($filtros, $campos='*', $extra='')
61: {
62: if(is_array($filtros)){
63: $condicion = ' where gn_clase._id>0 ';
64: foreach ($filtros as $key => $filtro) {
65: $condicion .= ' and '.$key.'="'.$filtro.'" ';
66: }
67: }
68: $query = "select ".$campos." from gn_clase ".$extra." ".$condicion;
69: $stmt = $this->bd->ejecutar($query);
70: if($clase = $this->bd->obtener_fila($stmt, 0)){
71: return $clase;
72: }
73: else{
74: echo $query;
75: return false;
76: }
77:
78: }
79: }
80: ?>