Example #1
7
 /**
  * Constructor.
  *
  * Connects to database with given connection string.
  *
  * @param string  $dsn        The connection string.
  * @param boolean $persistent Whether or not to establish a persistent connection.
  *
  * @throws SQLAnywhereException
  */
 public function __construct($dsn, $persistent = false)
 {
     $this->connection = $persistent ? @sasql_pconnect($dsn) : @sasql_connect($dsn);
     if (!is_resource($this->connection) || get_resource_type($this->connection) !== 'SQLAnywhere connection') {
         throw SQLAnywhereException::fromSQLAnywhereError();
     }
     // Disable PHP warnings on error.
     if (!sasql_set_option($this->connection, 'verbose_errors', false)) {
         throw SQLAnywhereException::fromSQLAnywhereError($this->connection);
     }
     // Enable auto committing by default.
     if (!sasql_set_option($this->connection, 'auto_commit', 'on')) {
         throw SQLAnywhereException::fromSQLAnywhereError($this->connection);
     }
     // Enable exact, non-approximated row count retrieval.
     if (!sasql_set_option($this->connection, 'row_counts', true)) {
         throw SQLAnywhereException::fromSQLAnywhereError($this->connection);
     }
 }
 /**
  * Create connection fybase
  * @param string  $dns        String connection for sybase
  * @param boolean $persistent Define connection for persistent
  */
 function __construct($dns, $autocommit = true, $persistent = false)
 {
     $this->dns = $dns;
     $this->persistent = $persistent;
     $this->autocommit = $autocommit;
     if (!function_exists('sasql_connect')) {
         throw new Exception("SQL Anywhere model not install in this server!", 100);
     }
     // Verifica se a conexão é persistente
     if ($this->persistent) {
         $this->connection = sasql_pconnect($this->dns);
     } else {
         $this->connection = sasql_connect($this->dns);
     }
     if (!$this->connection) {
         throw new Exception("Connection Problem :: " . sasql_error(), 101);
     }
     // Define option auto_commit
     if ($this->connection) {
         sasql_set_option($this->connection, 'auto_commit', $this->autocommit ? 'on' : 0);
         $this->dbinfo = array($dns, $autocommit, $persistent);
     }
 }
Example #3
0
 /**
  * Persistent database connection
  *
  * @access	private called by the base class
  * @return	resource
  */
 function db_pconnect()
 {
     //		return @sasql_pconnect("Dbn=$this->database;UID=$this->username;PWD=$this->password;ServerName=$this->server_name");
     return @sasql_pconnect("UID=dba;PWD=gjknfdf_rhtlbns;SERVER=app_12;DBN=lease12;HOST=front");
 }
Example #4
0
 /**
  * Persistent database connection
  *
  * @access	private called by the base class
  * @return	resource
  */
 function db_pconnect()
 {
     return @sasql_pconnect($this->_connect_string());
 }