Advertisement
Guest User

Untitled

a guest
Mar 28th, 2016
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. <?php
  2.  
  3. $database = '*LOCAL';
  4. $username = 'somebody';
  5. $password = 'something';
  6.  
  7. $options = [
  8. 'autocommit' => DB2_AUTOCOMMIT_ON,
  9. 'i5_naming' => DB2_I5_NAMING_ON,
  10. 'i5_libl' => 'LIB1 LIB2 LIB3',
  11. ];
  12.  
  13. $dbconn = db2_pconnect($database, $username, $password, $options);
  14.  
  15. if (!dbconn) {
  16. die();
  17. }
  18.  
  19. $sql = 'SELECT stuff FROM sometable WHERE x = ? ORDER BY seq#';
  20. $stmt = db2_prepare($dbconn, $sql);
  21.  
  22. if (!$stmt) {
  23. die();
  24. }
  25.  
  26. $params = ['blah'];
  27.  
  28. $result = db2_execute($stmt, $params);
  29.  
  30. if (!$result) {
  31. die();
  32. }
  33.  
  34. while ($row = db2_fetch_array($stmt)) {
  35. // do something with data
  36. }
  37.  
  38. // free the statement
  39. $stmt = '';
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement