Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $gaSql['user'] = "postgres";
- $gaSql['password'] = "password";
- $gaSql['db'] = "pg_testing";
- $gaSql['server'] = "localhost";
- $gaSql['link'] = pg_connect(
- "host=".$gaSql['server'].
- " dbname=".$gaSql['db'].
- " user=".$gaSql['user'].
- " password=".$gaSql['password']
- ) or die('Could not connect:' . pg_last_error());
- $sQuery = "SELECT * FROM users";
- $rResult = pg_query($gaSql['link'], $sQuery) or die(pg_last_error());
- $iTotal = pg_num_rows($rResult);
- echo $iTotal;
- output> 4
- while ($aRow = pg_fetch_array($rResult, null, PGSQL_ASSOC)) {
- print_r($aRow);
- }
- output>
- Array
- (
- [id] => 1
- [name] => John
- )
- Array
- (
- [id] => 2
- [name] => Smyth
- )
- Array
- (
- [id] => 3
- [name] => Arthur
- )
- Array
- (
- [id] => 4
- [name] => George
- )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement