Advertisement
Guest User

SqlPdo

a guest
Jun 23rd, 2016
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. <?php
  2.  
  3. $database = "nome_do_seu_banco";
  4. $username = "root";
  5. $password = "";
  6.  
  7. try {
  8. $con = new PDO("oci:dbname={$database}", $username, $password);
  9. }
  10.  
  11. catch(PDOException $exception){
  12. echo "Connection error: " . $exception->getMessage();
  13. }
  14.  
  15.  
  16.  
  17. $job = isset( $_GET['job'] ) ? $_GET['job'] : null;
  18.  
  19. $id = isset( $_GET['id'] ) && is_numeric( $_GET['id'] ) ? $_GET['id'] : null;
  20.  
  21. $sql = $con->prepare("SELECT CO21CODCOT FROM CO21T1 WHERE CO21CODCOT ='{$id}'");
  22. $sql->execute();
  23.  
  24. if( $sql->rowCount() >= 1 ){
  25.  
  26. while( $rows->$sql->fetch( PDO::FETCH_ASSOC ) )
  27. {
  28. //....
  29. }
  30.  
  31. }else{
  32.  
  33. // O que deseja fazer se não encontrar
  34. }
  35.  
  36.  
  37. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement