Advertisement
Guest User

Untitled

a guest
Sep 3rd, 2016
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. <?php
  2. $hostname = "MYIBMI";
  3. $user = "MYPROFILE";
  4. $password = "";//leave blank and prompt. (works in windows not sure if it will work in other situations)
  5. $pdoConnection = new PDO("odbc:" . $hostname, $user, $password);
  6.  
  7. $sql="SELECT * FROM MYLIB.MYTABLE WHERE NAME=:NAME AND CITY=:CITY";
  8. $stmt = $pdoConnection->prepare($sql);
  9. if (!$stmt)
  10. {
  11. echo implode($this->_pdoConnection->errorInfo());
  12. }
  13. else
  14. {
  15. $stmt->bindValue(":NAME", "Chuck");
  16. $stmt->bindValue(":CITY", "Orlando");
  17. }
  18.  
  19. if ($stmt->execute())
  20. {
  21. while ($row = $stmt->fetch(PDO::FETCH_ASSOC))
  22. {
  23. var_dump($row).PHP_EOL;
  24. }
  25. }
  26. else
  27. {
  28. echo 'statement failed with '.$stmt->errorInfo();
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement