public static function getAllByTipoContenidoYFecha($tipoContenido, $fecha_limite, $limit) { // Collection<Contenido> $contenidos = new ArrayList<Contenido>(); $contenidos = new ArrayCollection(); /* Contenido */ $c; /* MySQLAccess */ $mysql = new MySQLAccess(); try { /* java.sql.CallableStatement */ $cstm = $mysql->IniciarStoredProc("CALL listarcontenidostipofecha(?, ?)"); $cstm->bindParam(1, TipoContenido::name(tipo), \PDO::PARAM_STR); $cstm->bindParam(2, $fecha_limite->format('Y-m-d'), \PDO::PARAM_STR); /* ResultSet */ $flag = $cstm->execute(); $rs = $cstm->fetchAll(); /*int */ $cant = 0; while ($rs . next() && $limit > $cant) { try { $c = self::mapear($rs, $mysql); if (isset($c)) { $contenidos->set($c->getID(), $c); $cant += 1; } } catch (\Exception $ex) { print_r($ex->getMessage()); } } // $rs.close(); $cstm->closeCursor(); $cstm = null; } catch (\PDOException $ex) { /*do nothing*/ print_r($ex->getMessage()); } finally { $mysql->close(); } return $contenidos; }
public static function getAll() { // Collection<Categoria> categorias = new ArrayList<Categoria>(); $categorias = new ArrayCollection(); // MySQLAccess mysql = new MySQLAccess(); $mysql = new MySQLAccess(); try { // java.sql.CallableStatement cstm = mysql.IniciarStoredProc("{CALL listarcategorias()}"); $cstm = $mysql->IniciarStoredProc("CALL listarcategorias()"); /*ResultSet $rs = $cstm->executeQuery();*/ $cstm->execute(); $rs = $cstm->fetchAll(); self::wrapEntidad($rs, $categorias); // $rs->close(); $cstm->closeCursor(); $cstm = null; } catch (Exception $ex) { /*do nothing??*/ print_r($ex . getMessage()); } finally { $mysql->close(); } return $categorias; }