Ver Mensaje Individual
  #1 (permalink)  
Antiguo 06/12/2008, 10:52
kike_17
 
Fecha de Ingreso: diciembre-2008
Mensajes: 1
Antigüedad: 15 años, 5 meses
Puntos: 0
...ayuda con POO en PHP

hola soy nuevo en esto y estoy tratando de hacer una aplicacion en php con POO,.....
Porfavor necesito que alguien me ayude....el problema es que no me muestra los datos de la consulta en la web
aqui les dejo mi aplicacion ....
de antemano muchas gracias por las respuestas...

conexionBD.php

<?php
class ConexionBD {

public static function getConexion() {
try{
@$cn = mysql_connect("localhost", "root", "");
if(mysql_errno($cn))
throw new Exception(mysql_error($cn));

@mysql_select_db("encuesta");
if(mysql_errno($cn))
throw new Exception(mysql_error($cn));

return $cn;
} catch(Exception $e) {
error_log("\n" . $e->getMessage(),3, "../Logging/Error.log");
throw new Exception("ERROR: Fallo la conexión");
}
}

}
?>



llamadaTO.php

<?php
class llamadaTO {
private $id;
private $origen;
private $destino;
private $fecha;
private $duracion;
private $contexto;
private $canal;
private $p1;
private $p2;
private $p3;

public function setID($Value) {
$this->id = $Value;
}
public function getID() {
return $this->id;
}
public function setOrigen($Value) {
$this->origen = $Value;
}
public function getOrigen() {
return $this->origen;
}
public function setDestino($Value) {
$this->destino = $Value;
}
public function getDestino() {
return $this->destino;
}
public function setFecha($Value) {
$this->fecha = $Value;
}
public function getFecha() {
return $this->fecha;
}
public function setDuracion($Value) {
$this->duracion = $Value;
}
public function getDuracion() {
return $this->duracion;
}
public function setContexto($Value) {
$this->contexto = $Value;
}
public function getContexto() {
return $this->contexto;
}
public function setCanal($Value) {
$this->canal = $Value;
}
public function getCanal() {
return $this->canal;
}
public function setP1($Value) {
$this->p1 = $Value;
}
public function getP1() {
return $this->p1;
}
public function setP2($Value) {
$this->p2 = $Value;
}
public function getP2() {
return $this->p2;
}
public function setP3($Value) {
$this->p3 = $Value;
}
public function getP3() {
return $this->p3;
}

}

?>


vistaLlamada.php

<?php
session_start();
require_once("TO/llamadaTO.php");

if(isset($_SESSION["Numero"]))
$Numero = $_SESSION["Numero"];

?>
<head>
</head>
<body>
<form id="form1" name="form1" method="post" action="Controller/llamadaController.php">
<input type="hidden" name="NUMERO" value="TRAER_X_NUM" />
<table width="200" border="1">
<tr>
<td>Numero</td>
<td><input type="text" name="txtNumero" id="txtNumero" value="<?=$Numero?>"/></td>
<td><input type="submit" name="button" id="button" value="traer" /></td>
</tr>
</table>
<table width="949" border="0" bordercolor="#660033">
<tr bgcolor="#C6C6C6">
<td colspan="9" bordercolor="#FFFFFF" bgcolor="#C6C6C6"><div align="center" class="Estilo2">LLAMADAS</div></td>
</tr>
<tr bgcolor="#FFFFCC">
<td width="58"><div align="center">Origen</div></td>
<td width="92"><div align="center">Destino</div></td>
<td width="78"><div align="center">Fecha</div></td>
<td width="106"><div align="center">Duracion</div></td>
<td width="91"><div align="center">Contexto </div></td>
<td width="139"><div align="center">Canal</div></td>
<td width="131"><div align="center">Pregunta 1</div></td>
<td width="92"><div align="center">Pregunta 2</div></td>
<td width="104"><div align="center">Pregunta 3</div></td>
</tr>
<?php
if(isset($_SESSION["arrayNum"])) {
$arrayNum = unserialize($_SESSION["arrayNum"]);
foreach($arrayNum as $value) {
?>
<tr>
<td><?=$value->getOrigen() ?></td>
<td><?=$value->getDestino() ?></td>
<td><?=$value->getFecha() ?></td>
<td><?=$value->getDuracion() ?></td>
<td><?=$value->getContexto() ?></td>
<td><?=$value->getCanal() ?></td>
<td><?=$value->getP1() ?></td>
<td><?=$value->getP2() ?></td>
<td><?=$value->getP3() ?></td>
</tr>
<?php }



}
?>
</table>
</form>

<p>&nbsp;</p>
<p>&nbsp;</p>
</body>


llamadaController.php


<?php
session_start;
require_once("../TO/llamadaTO.php");
require_once("../Model/llamadaMo.php");

function TraerXNum($Numero) {
$objLlamModel = new llamadaModel();
return $objLlamModel->TraerXNumero($Numero);

}

switch($_REQUEST["NUMERO"]) {

case "TRAER_X_NUM":
$Numero = $_REQUEST["txtNumero"];
$arrayNum = TraerXNum($Numero);
$_SESSION["arrayNum"] = serialize($arrayNum);
$_SESSION["Numero"] = $Numero;
header("location:../vistaLlamada.php");
break;

}
?>

llamadaMo.php

<?php
require_once("../TO/llamadaTO.php");
require_once("../BD/ConexionBD.php");

class llamadaModel{
public function TraerXNumero($Numero) {
$arrayNum = array();



$cn = ConexionBD::getConexion();

@$rs = mysql_query("Select * From llamada
Where destino Like '$Numero%'", $cn);
if(mysql_errno($cn))
throw new Exception(mysql_error($cn));

$R= 0;
while($fila = mysql_fetch_assoc($rs)) {
$objLlamTO = new llamadaTO();

$objLlamTO->setID($fila["ID"]);
$objLlamTO->setFecha($fila["fecha"]);
$objLlamTO->setDuracion($fila["duracion"]);
$objLlamTO->setOrigen($fila["origen"]);
$objLlamTO->setDestino($fila["destino"]);
$objLlamTO->setContexto($fila["contexto"]);
$objLlamTO->setCanal($fila["canal"]);
$objLlamTO->setP1($fila["P1"]);
$objLlamTO->setP2($fila["P2"]);
$objLlamTO->setP3($fila["P3"]);

$arrayNum[$R] = $objLlamTO;
$R++;
}

return $arrayNum;

}
}
?>