コード例 #1
0
 /**
  * Connect to database by using the given DSN string
  *
  * @access private
  * @param  string DSN string
  * @return mixed  Object on error, otherwise bool
  */
 function _connect($dsn)
 {
     if (is_string($dsn) || is_array($dsn)) {
         if (!$this->db) {
             $this->db = ADONewConnection($dsn);
             if ($err = ADODB_Pear_error()) {
                 return PEAR::raiseError($err);
             }
         }
     } else {
         return PEAR::raiseError('The given dsn was not valid in file ' . __FILE__ . ' at line ' . __LINE__, 41, PEAR_ERROR_RETURN, null, null);
     }
     if (!$this->db) {
         return PEAR::raiseError(ADODB_Pear_error());
     } else {
         return true;
     }
 }
コード例 #2
0
 /**
  * Connect to database by using the given DSN string
  *
  * @access private
  * @param  string DSN string
  * @return mixed  Object on error, otherwise bool
  */
 function _connect($dsn)
 {
     if (is_string($dsn) || is_array($dsn)) {
         if (!$this->db) {
             $this->db =& ADONewConnection($this->options['db_type']);
             if ($err = ADODB_Pear_error()) {
                 return PEAR::raiseError($err);
             }
         }
         $dbconnected = $this->db->Connect($this->options['db_host'], $this->options['db_user'], $this->options['db_pass'], $this->options['db_name']);
         if (!$dbconnected) {
             PEAR::raiseError('Unable to connect to database');
         }
     } else {
         return PEAR::raiseError('The given dsn was not valid in file ' . __FILE__ . ' at line ' . __LINE__, 41, PEAR_ERROR_RETURN, null, null);
     }
     if (!$this->db) {
         return PEAR::raiseError(ADODB_Pear_error());
     } else {
         return true;
     }
 }