Funcion Buscar Datos
De CidesaWiki
(Diferencias entre revisiones)
(New page: public static function BuscarDatos($sql,&$output) { $con = sfContext::getInstance()->getDatabaseConnection($connection='propel'); $stmt = $con->createStatement(); $rs = $stmt->ex...) |
|||
Línea 1: | Línea 1: | ||
+ | <pre> | ||
public static function BuscarDatos($sql,&$output) | public static function BuscarDatos($sql,&$output) | ||
{ | { | ||
Línea 25: | Línea 26: | ||
if (count($rs)>0) return true; else return false; | if (count($rs)>0) return true; else return false; | ||
} | } | ||
+ | </pre> |
Revisión de 18:42 13 abr 2007
public static function BuscarDatos($sql,&$output) { $con = sfContext::getInstance()->getDatabaseConnection($connection='propel'); $stmt = $con->createStatement(); $rs = $stmt->executeQuery($sql, ResultSet::FETCHMODE_NUM); $i = pg_num_fields($rs->getResource()); $fieldname = array(); $result = array(); $output = array(); for ($j = 0; $j < $i; $j++) { $fieldname[] = pg_field_name($rs->getResource(),$j); } while ($rs->next()) { $a=0; while ($a < $i) { $fila = $rs->getRow(); $result[$fieldname[$a]] = $fila[$a]; $a++; } $output[] = $result; } if (count($rs)>0) return true; else return false; }