2 // vim: set binary expandtab tabstop=4 shiftwidth=4 textwidth=80:
3 // +--------------------------------------------------------------------+
4 // | Ministerio de Economía |
5 // | AI (Administrador de Intranet) |
6 // +--------------------------------------------------------------------+
7 // | This file is part of AI. |
9 // | AI is free software; you can redistribute it and/or modify |
10 // | it under the terms of the GNU General Public License as published |
11 // | by the Free Software Foundation; either version 2 of the License, |
12 // | or (at your option) any later version. |
14 // | AI is distributed in the hope that it will be useful, but |
15 // | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
17 // | General Public License for more details. |
19 // | You should have received a copy of the GNU General Public License |
20 // | along with Hooks; if not, write to the Free Software Foundation, |
21 // | Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
22 // +--------------------------------------------------------------------+
23 // | Creado: Fri Jul 18 18:19:35 2003 |
24 // | Autor: Leandro Lucarella <llucar@mecon.gov.ar> |
25 // +--------------------------------------------------------------------+
31 require_once 'AI/DBObject.php';
34 // +X2C Class 524 :AI_DBTreeObject
40 class AI_DBTreeObject extends AI_DBObject {
42 * Grupos de secciones que tiene este grupo.
47 var $_hijos = array();
64 * @param int $id Identificador del objecto.
65 * @param string $confFile Configuracin del objeto.
70 function AI_DBTreeObject($id = 0, $confFile = '') // ~X2C
72 parent::AI_DBObject($id, $confFile);
78 * @param mixed $db Base de datos o resultado de donde cargar los hijos.
83 function cargarHijos($db) // ~X2C
85 $id_field = $this->conf['id'];
86 $id_padre = $this->conf['padre'];
87 $tabla = $this->conf['base'].'.'.$this->conf['tabla'];
88 $id = intval($this->$id_field);
89 if (is_a($db, 'db_result')) {
92 // Si no es un resultado, hago el query.
94 $result = $db->query("SELECT * FROM $tabla WHERE $id_padre = $id");
95 if (DB::isError($result)) {
99 $this->_hijos = array();
100 $clase = get_class($this);
102 $err = $hijo->cargar($result);
103 while (!PEAR::isError($err)) {
104 $this->_hijos[] = $hijo->__clone();
105 $err = $hijo->cargar($result);
107 // Si no hay mas resultados, entonces terminó bien.
108 if (AI_Error::isError($err)
109 and $err->getCode() == AIERROR_NO_RESULTADOS) {
112 // Si no, se devuelve el error.
117 } // -X2C Class :AI_DBTreeObject