Ver Mensaje Individual
  #1 (permalink)  
Antiguo 04/03/2011, 18:53
jdlfuente
 
Fecha de Ingreso: octubre-2007
Mensajes: 12
Antigüedad: 16 años, 6 meses
Puntos: 1
php y Postgres

hola tengo el siguiente problema no se por que falla lo miro y la verdad me desconcertó alguien me da una mano por favor

tengo esta siguiente clase

<?php
//require_once"../../mios/MyConexionPSQL.php";
require_once"../Conexion/MyConexionPSQL.php";

class Departamentos{

protected $id_depto;
protected $departamento;
protected $provincia_id;
protected $con;

function __construct(){

$this->con = new Conexion();
}

function listarDepartamentos(){

$sql = "select * from tb_departamentos";
$datos = $this->con->runSQL($sql);
return $datos;



}

//
function __destruct(){

}




}


$dpto = new Departamentos();
$result = $dpto->listarDepartamentos();
for($i=0;$i<count($result);$i++){

echo $result[$i]->id.','.$result[$i]->departamento;


}

?>

esta clase anda de 10 cuando desde el mismo archivo, pero cuando lo llamo desde otro por ejemplo
vistadepto.php

que seria este de aqui abajo:

<?php
require_once"../../MODELOS/personas/departamentosModelo.php";
?>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html" />
<title>vista</title>
</head>
<body>
<form method="POST" name='formulario' id='formulario' >

<table width='100%' cellspacing="1" cellpadding="1">
<tr>
<td class='visor'><img src='/hospitalmvc/vistas/css/img/asterisco.gif' width='14px' height='14px'>&nbsp; Datos de Barrio </td>
</tr>
<tr>

</tr>
<tr>
<td>
<div id="datos">
<table width='100%' valign='middle'>
<tr>
<td width='10%'><label>Barrio:</label></td>
<td width='45%'><input type='text' id='barrio' name='barrio' size='25'/></td>
<td width='45%'>Departamento :
<label for="DEPARTAMENTOS"></label>

<?php
$dpto = new Departamentos();
$result = $dpto->listarDepartamentos();
?>
<select name='departamento_id' id="departamento_id">
<?php
for($i=0;$i<count($result);$i++){
?>
<option value="<?php echo $result[$i]->id ?>"><?php echo $result[$i]->departamento ?></option>
<?php
}
?>
</select>
</select> </td>
</tr>
<tr>
<td></td>
<td colspan="2">
<label for="select">

<input type="button" name="Submit" value="Guardar" />
</label> </td>
</tr>
</table>
</div>
</td>
</tr>
</table>

</form>

</body>
</html>

de aqui no me funciona me sale el siguiente error : "
Warning: require_once(../Conexion/MyConexionPSQL.php) [function.require-once]: failed to open stream: No such file or directory in C:\wamp\www\prueba\MODELOS\personas\departamentosM odelo.php on line 3

Fatal error: require_once() [function.require]: Failed opening required '../Conexion/MyConexionPSQL.php' (include_path='.;C:\php5\pear') in C:\wamp\www\prueba\MODELOS\personas\departamentosM odelo.php on line 3

"
me urge saber por que es la falla.

mi archivo de conexion es este


MyConexionPSQL.php

<?php
class Conexion {
private $host;

private $user;

private $pass;

private $dbname;

public $id_conexion;

function __construct()
{
//$this->host = '192.168.50.3';
$this->host = 'localhost';
$this->user = 'postgres'; //$user;
$this->pass = 'postgres';//$pass;
$this->dbname = 'MYDB';
$this->IConexion();

}


function IConexion(){
$this->id_conexion = pg_connect("host={$this->host} port='5432' dbname={$this->dbname} user={$this->user} password={$this->pass}") ;

if (!$this->id_conexion){
$msj = utf8_decode("<script languaje=javascript> alert('No se Puede Conectar ala base de Datos');</script>");
print($msj);

exit;

}

}



public function runSQL($sql)
{
try{
$array = NULL;
$res = pg_query($this->id_conexion,$sql);
//echo $sql;
if(!$res){
throw new Exception ("Error SQL : ".pg_last_error($this->id_conexion));
}
while ($dato = pg_fetch_object($res)){
$array[]=$dato;

}
pg_free_result($res);
return $array;
}
catch (Exception $e) {
echo $e->getMessage();
}
}






public function SQL($sql){

try{
$res = pg_query($this->id_conexion,$sql);

if(!$res){
throw new Exception ("Error SQL".pg_last_error($this->id_conexion));
}

return true; // $res;
}
catch (Exception $e){
echo $e->getMessage();
}

}




public function Get_IdConexion()
{
return $this->id_conexion;
}

public function cerrarConexion()
{
pg_close($this->id_conexion);
}


function __destruct()
{
//$this->cerrarConexion($this->pgdb);
}

}


?>