Funcion Buscar Datos
De CidesaWiki
(Diferencias entre revisiones)
Línea 25: | Línea 25: | ||
} | } | ||
if (count($rs)>0) return true; else return false; | if (count($rs)>0) return true; else return false; | ||
+ | } | ||
+ | </pre> | ||
+ | <pre> | ||
+ | public function executeSQL2() | ||
+ | { | ||
+ | $result=array(); | ||
+ | $sql = "Select * From npasicaremp limit 10"; | ||
+ | if (Herramientas::BuscarDatos($sql,&$result)) | ||
+ | { | ||
+ | $cedula = $result[1]['codemp']; | ||
+ | $nombre = $result[1]['nomemp']; | ||
+ | } | ||
} | } | ||
</pre> | </pre> |
Revisión de 18:48 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; }
public function executeSQL2() { $result=array(); $sql = "Select * From npasicaremp limit 10"; if (Herramientas::BuscarDatos($sql,&$result)) { $cedula = $result[1]['codemp']; $nombre = $result[1]['nomemp']; } }