×

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: Sep 13, 2017 10:14 AM
Views: 2
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. <?
  2.  
  3.  
  4. if (extension_loaded('sybase_ct')) {
  5.         echo 'PDO laoded!';
  6.     }
  7.  
  8. if(function_exists('sybase_connect')){
  9.    echo "function exists!";
  10. }
  11.  
  12.  
  13. $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)
  14. $res=sybase_query("SELECT test FROM test",$conn);
  15.  
  16. while($arrConfig = sybase_fetch_array($res))
  17.         print_r($arrConfig);
  18.  
  19.  
  20. // this Connection doesnt work! maybe it will wor good when
  21.  
  22. <?php
  23.  
  24.  
  25.  
  26. try{
  27.  
  28.     $conn = new PDO("dblib:host=555.555.555.21:145;dbname=test.db", "DBA", "sql");
  29.     if ($conn)
  30.         echo "Ok Verbunden!";
  31.  
  32.     $whereArtikel='5';
  33.  
  34.     $sql="SELECT test FROM test WHERE test = :art";
  35.     if($stmt=$conn->prepare($sql)){
  36.         if ($stmt->execute([':art'=>$whereArtikel])){
  37.             while ($row=$stmt->fetch(PDO::FETCH_OBJ)){
  38.                 echo $row->test."<br/>";
  39.             }
  40.         }
  41.  
  42.     }
  43.  
  44.  
  45. }catch (PDOException $e){
  46.     echo $e->getMessage();
  47. }
  48. ?>