/** * @funcionalidad: si el resultado de la consulta devuelve un array * llamamos a esta funcion para guardarlo y retornarlo * @param type $consulta resultado de la consulta pasado por parametro * @return type devolvemos un array con los datos obtenidos en la consulta */ function resultadoArray($consulta) { $array = []; if ($consulta->fetch()) { while ($f = $consulta->fetch()) { $array[] = $f; } } return $array; }
/** * Convertie un statement SQL (un seul enregistrement) en tableau PHP * @param type $paramStatementObjet * @return type */ public static function convertSqlStatementFirstRowToArray($paramStatementObjet) { if ($paramStatementObjet) { $return = $paramStatementObjet->fetch(PDO::FETCH_ASSOC); $paramStatementObjet->closeCursor(); } return $return; }
/** * Replacement for mysql_fetch_array (MYSQL_ASSOC) * Returns one line of associative arrays * * @param type $rst * @return type */ function umc_mysql_fetch_array($rst) { XMPP_ERROR_trace(__FUNCTION__, func_get_args()); if (!$rst) { XMPP_ERROR_trigger("tried fetch_array on erroneous recordset"); return false; } $row = $rst->fetch(PDO::FETCH_ASSOC); return $row; }
/** * @funcionalidad: si el resultado de la consulta devuelve un array * llamamos a esta funcion para guardarlo y retornarlo * Lo utilizaremos en momentos que tengamos claves enteras y strings en el mismo array * @param type $consulta resultado de la consulta pasado por parametro * @return type devolvemos un array con los datos obtenidos en la consulta */ function resultadoArray($consulta) { $array = array(); //if($consulta->fetch()){ while ($f = $consulta->fetch()) { $array[] = $f; } //} return $array; }
/** * Applique le pager à un template */ public function run(&$tpl) { global $pdo; $this->sql->execute(); $this->sqlCount->execute(); $total = $this->sqlCount->fetch(); $total = $total[0]; if ($this->start < 0 || $this->start > $total) { throw new Exception('Out of range'); } $hasPrev = $this->start - $this->nbByPage >= 0; $hasNext = $this->start + $this->nbByPage < $total; $table = array('total' => $total, 'prev' => urldup(array($this->key => $hasPrev ? $this->start - $this->nbByPage : 0)), 'next' => urldup(array($this->key => $hasNext ? $this->start + $this->nbByPage : $this->start)), 'showNext' => $hasNext, 'showPrev' => $hasPrev, 'rows' => array()); while ($line = $this->sql->fetch()) { $table['rows'][] = $line; } $tpl->assign($this->prepose . 'table', $table); }