<?php $this->execSql($sqlcmd); for ($i = 0; $i < $this->num; $i++) { $row = almdata::fetchRow(null, false); $array_rows[] = $row[0]; }
<?php //FIXME: Solo usa la primera llave, qué pasa con tablas que usan más de una llave? if (!$sqlcmd) { $key = $this->keys[0]; if (isset($this->dd[$this->name])) { $sqlcmd = "SELECT {$key}, {$this->name} FROM {$this->name} _WHERE_ ORDER BY {$this->name}.{$this->name}"; } else { $sqlcmd = "SELECT {$key}, {$key} AS {$this->name} FROM {$this->name} _WHERE_ ORDER BY {$this->name}"; } } /* $sqlcmd no contiene comando sql sino nombre de la tabla !?! */ global $global_dd; if (!preg_match("/^SELECT/", $sqlcmd)) { $table = $sqlcmd; $id = $global_dd[$table]['keys'][0]; $descriptor = $global_dd[$table]['descriptor']; $sqlcmd = "SELECT {$id}, {$descriptor} FROM {$sqlcmd} _WHERE_ ORDER BY {$descriptor}"; } if ($filter) { $sqlcmd = preg_replace('/_WHERE_/ ', "WHERE {$filter}", $sqlcmd); } else { $sqlcmd = preg_replace('/_WHERE_/ ', '', $sqlcmd); } $result = $this->query($sqlcmd); $num = almdata::rows($result); $menu = array(); for ($i = 0; $i < $num; $i++) { $r = almdata::fetchRow($result, false); $menu[$r[0]] = $r[1]; }
<?php if ($cache === true && file_exists($this->filecache) && time() - filemtime($this->filecache) <= ALM_CACHE_TIME) { $array_rows = unserialize(file_get_contents($this->filecache)); } else { for ($i = 0; $i < $this->num; $i++) { $row = almdata::fetchRow($this->data); if (isset($row[$this->key])) { if ($row[$this->key] == $this->current_id) { $this->current_record = $row; } } if ($this->html) { foreach ($row as $key => $val) { $row[$key] = htmlentities($val, ENT_COMPAT, 'UTF-8'); } } $array_rows[] = $row; } if (isset($array_rows) && $cache === true) { file_put_contents($this->filecache, serialize($array_rows)); } }
/** * Lee un registro de la tabla usando un comando SQL * @param string $sqlcmd comando SQL a usar * @return array con el registro (devuelto por *_fetch_row) */ function readRecordSQL($sqlcmd) { $this->execSql($sqlcmd); $row = almdata::fetchRow($this->data); $this->current_record = $row; return $row; }