Skip to content

Instantly share code, notes, and snippets.

@nihilismus
Created May 31, 2015 03:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nihilismus/ab41247e27ef2c4580b8 to your computer and use it in GitHub Desktop.
Save nihilismus/ab41247e27ef2c4580b8 to your computer and use it in GitHub Desktop.
Ejemplo de uso de pgsql y pdo_pgsql
// Módulo pgsql:
<?php
$c_pgsql = pg_connect("host=127.0.0.1 user=alu12345 password=12345 dbname=bd12345 port=1111");
$r_pgsql = pg_query($c_pgsql, "select version()");
$r = pg_fetch_assoc($r_pgsql);
echo $r['version'];
?>
// Módulo pdo_pgsql:
<?php
$c_pdo = new PDO("pgsql:host=127.0.0.1 user=alu12345 password=12345 dbname=bd12345 port=1111");
$r_pdo = $c_pdo->query("select version()");
$r = $r_pdo->fetch(PDO::FETCH_ASSOC);
echo $r['version'];
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment