note 67938 added to ref.pgsql
| From: | framirez at akori dot fr | Date: | Fri, 07 Jul 2006 02:07:57 +0000 |
| Subject: | note 67938 added to ref.pgsql | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-114525@lists.php.net to get a copy of this message | ||
/*
@author: FabÃan Andrés RamÃrez Sepúlveda
@owner : Proyecto
@email : framirez@akori.fr
@clase : framework->postgresql.php
@desc : Clase para la conexion con una base de datos PostgreSQL
$Id: postgresql.php 133 2006-07-06 20:30:23Z framirez $
*/
class postgresql
{
var $enlace;
/* conecta con la db*/
function conectar()
{
if (!$this->enlace=pg_connect("host=localhost port=5432 user=framirez password=15550
dbname=framirez", PGSQL_CONNECT_FORCE_NEW))
{
die('Error conectando con la base de datos: ' . $host);
}
}
/* Realiza las consultas */
function consulta($sentenciaSQL)
{
if(!$this->consulta=pg_exec($sentenciaSQL))
{
die('Error realizando la consulta: ' . $sentenciaSQL);
}
}
/* Obtiene los resultados */
function obtenerResultado(){
$this->resultado=pg_fetch_Array($this->consulta);
return $this->resultado;
}
/* Desconecta de la base de datos */
function desconectar()
{
$this->desconectar=pg_close();
}
/* Funciones adicionales */
function version()
{
$version = pg_version($this->enlace);
return $version;
}
}
To execute:
/* Invocación de la clase */
$postgresql = new postgresql();
$postgresql->conectar();
$postgresql->consulta("SELECT * from noticias");
while($source=$postgresql->obtenerResultado()){
printf($source['idnoticia']);
}
$postgresql->desconectar();
/* Fin de la invocación a la clase */
----
Server IP: 216.194.113.175
Probable Submitter: 200.120.0.51
----
X-Spam-Status: Yes, hits=7.4 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER,
HEAD_ILLEGAL_CHARS autolearn=no version=2.64
----
Manual Page -- http://www.php.net/manual/en/ref.pgsql.php
Edit -- http://master.php.net/note/edit/67938
Del: integrated -- http://master.php.net/note/delete/67938/integrated
Del: useless -- http://master.php.net/note/delete/67938/useless
Del: bad code -- http://master.php.net/note/delete/67938/bad+code
Del: spam -- http://master.php.net/note/delete/67938/spam
Del: non-english -- http://master.php.net/note/delete/67938/non-english
Del: in docs -- http://master.php.net/note/delete/67938/in+docs
Del: other reasons-- http://master.php.net/note/delete/67938
Reject -- http://master.php.net/note/reject/67938
Search -- http://master.php.net/manage/user-notes.php