示例#1
0
 function __construct()
 {
     /* disable scrollable result sets since they are not compatible with lobs */
     ini_set("ingres.scrollable", false);
     /* the demoapp uses iconv to convert UTF-16<-->UTF-8
      * TODO : remove this dependence 
      */
     ini_set("ingres.utf8", false);
     $connectString = "";
     @session_start();
     if (isset($_SESSION['host']) && $_SESSION['host'] != "(local)") {
         //make connection string with dynamic vnode syntax:
         // @hostname,protocol,InstanceName[user,password]::database
         // for example @127.0.0.1,tcp_ip,II[apache,123]::demodb
         $connectString = "@";
         $connectString .= $_SESSION['host'] . ",";
         $connectString .= "tcp_ip,";
         $connectString .= $_SESSION['instance'];
         $connectString .= "[" . $_SESSION['user'] . "," . $_SESSION['password'] . "]";
         $connectString .= "::" . $_SESSION['database'];
         $this->Connection = ingres_connect($connectString, "", "");
     } else {
         //just connect to a local Ingres Instance
         if (isset($_SESSION['user']) && isset($_SESSION['password']) && isset($_SESSION['database'])) {
             $this->Connection = ingres_connect($_SESSION['database'], $_SESSION['user'], $_SESSION['password']);
         } else {
             $this->Connection = ingres_connect(DATABASE, USER, PASSWORD);
         }
     }
     if (ingres_errno($this->Connection) != 0) {
         throw new Exception("Error occured: Errno" . ingres_errno() . " Error: " . ingres_error() . "connection-String:" . $connectString, 4);
     }
 }
 function connect($host, $name, $user, $pass)
 {
     if (!function_exists("ingres_connect")) {
         trigger_error("FATAL ERROR: Ingres support not available.  Please check your configuration.", E_USER_ERROR);
         return;
     }
     if ("localhost" != $host) {
         trigger_error("FATAL ERROR: Ingres server host has to be 'localhost'", E_USER_ERROR);
         return;
     }
     if (!$name) {
         trigger_error("FATAL ERROR: Ingres driver has to select a specific database on 'localhost'", E_USER_ERROR);
         return;
     }
     if (null == ($this->link = ingres_connect($name, $user, $pass))) {
         trigger_error("FATAL ERROR: Connection to Ingres server failed", E_USER_ERROR);
         return;
     }
     return $this->link;
 }
示例#3
0
 function connect_ingres($db, $user, $pass)
 {
     $this->link_ingres = ingres_connect($db, $user, $pass);
     if ($this->link_ingres) {
         return $this->link_ingres;
     } else {
         print nl2br("Could not connect. \n");
         return false;
     }
 }