Advertisement
Guest User

Untitled

a guest
Jun 25th, 2017
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.78 KB | None | 0 0
  1. <?php
  2.  
  3. $conn = pg_pconnect("dbname=publisher");
  4. if (!$conn) {
  5.   echo "An error occured.\n";
  6.   exit;
  7. }
  8.  
  9. $result = pg_query($conn, "SELECT author, email FROM authors");
  10. if (!$result) {
  11.   echo "An error occured.\n";
  12.   exit;
  13. }
  14.  
  15. $arr = pg_fetch_array($result, 0, PGSQL_NUM);
  16. echo $arr[0] . " <- Row 1 Author\n";
  17. echo $arr[1] . " <- Row 1 E-mail\n";
  18.  
  19. // As of PHP 4.1.0, the row parameter is optional; NULL can be passed instead,
  20. // to pass a result_type.  Successive calls to pg_fetch_array will return the
  21. // next row.
  22. $arr = pg_fetch_array($result, NULL, PGSQL_ASSOC);
  23. echo $arr["author"] . " <- Row 2 Author\n";
  24. echo $arr["email"] . " <- Row 2 E-mail\n";
  25.  
  26. $arr = pg_fetch_array($result);
  27. echo $arr["author"] . " <- Row 3 Author\n";
  28. echo $arr[1] . " <- Row 3 E-mail\n";
  29.  
  30. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement