×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: PHP
Posted by: userc865b
Added: Sep 13, 2017 9:36 AM
Modified: Nov 8, 2017 10:06 AM
Views: 5
Tags: php
connects to sybase! SQL-Anywhere Network Server must run (where SQL Anywhere is installed)!
When Starting SQL-Anywhere Network Server yo must select the database file the nework server refers to.
In the widows of SQL-Anywhere Network Server you can see the port the SQL-Anywhere Network Server listen to request for the selected database.
This port must be put in the php connection Stirng in the sybase_connect function!

the port stands for the database!!!! on the host computer.
  1. <?php
  2.  
  3.  
  4.  
  5. if (extension_loaded('sybase_ct')) {
  6.         echo 'PDO laoded!';
  7.     }
  8.  
  9. if(function_exists('sybase_connect')){
  10.    echo "function exists!";
  11. }
  12.  
  13.  
  14. $conn=sybase_connect("192.555.55.55:2465","DBA","sql"); // the ip of Host where SQL Anywhere Server is running and the port  (port stands for database, the port listen to)
  15. $res=sybase_query("SELECT test FROM test",$conn);
  16.  
  17. while($arrConfig = sybase_fetch_array($res))
  18.         print_r($arrConfig);
  19.  
  20. ########################################################
  21.  
  22. $host="182.172.5.10";
  23. $port="3644";
  24. $user="user";
  25. $pass="password";
  26.  
  27. $conn=sybase_connect("$host:$port",$user,$pass); // the ip of Host where SQL Anywhere Server is running and the port
  28. $res=sybase_query("SELECT ArtikelNr FROM tblArtikel",$conn);
  29.  
  30. while($arrConfig = sybase_fetch_array($res))
  31.     print_r($arrConfig);
  32. ###########################################################
  33.  
  34. try{
  35.  
  36.     $conn = new PDO("dblib:host=555.555.555.21:145;dbname=test.db", "DBA", "sql");
  37.     if ($conn)
  38.         echo "Ok Verbunden!";
  39.  
  40.     $whereArtikel='5';
  41.  
  42.     $sql="SELECT test FROM test WHERE test = :art";
  43.     if($stmt=$conn->prepare($sql)){
  44.         if ($stmt->execute([':art'=>$whereArtikel])){
  45.             while ($row=$stmt->fetch(PDO::FETCH_OBJ)){
  46.                 echo $row->test."<br/>";
  47.             }
  48.         }
  49.  
  50.     }
  51.  
  52.  
  53. }catch (PDOException $e){
  54.     echo $e->getMessage();
  55. }
  56. ?>