コード例 #1
0
ファイル: MDB.php プロジェクト: rhertzog/lcs
 /**
  * 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)) {
         $this->db =& MDB::Connect($dsn);
     } elseif (get_parent_class($dsn) == "mdb_common") {
         $this->db = $dsn;
     } elseif (is_object($dsn) && MDB::isError($dsn)) {
         return PEAR::raiseError($dsn->getMessage(), $dsn->code);
     } else {
         return PEAR::raiseError('The given dsn was not valid in file ' . __FILE__ . ' at line ' . __LINE__, 41, PEAR_ERROR_RETURN, null, null);
     }
     if (MDB::isError($this->db) || PEAR::isError($this->db)) {
         return PEAR::raiseError($this->db->getMessage(), $this->db->code);
     } else {
         return true;
     }
 }
コード例 #2
0
 /**
  * Constructor
  *
  * @param mixed Array with connection info or dsn string
  */
 function Cache_Container_mdb($options)
 {
     $this->db =& MDB::Connect($options);
     if (MDB::isError($this->db)) {
         return new Cache_Error('MDB::connect failed: ' . $this->db->getMessage(), __FILE__, __LINE__);
     } else {
         $this->db->setFetchMode(MDB_FETCHMODE_ASSOC);
     }
     $this->setOptions($options, array_merge($this->allowed_options, array('dsn', 'cache_table')));
 }
コード例 #3
0
ファイル: mdb.php プロジェクト: Blu2z/implsk
 /**
  * Contructor
  *
  * Mail_Queue_Container_mdb:: Mail_Queue_Container_mdb()
  *
  * @param mixed $options    An associative array of option names and
  *                          their values. See MDB_common::setOption
  *                          for more information about connection options.
  *
  * @access public
  */
 function Mail_Queue_Container_mdb($options)
 {
     if (!is_array($options)) {
         return new Mail_Queue_Error(MAILQUEUE_ERROR_NO_OPTIONS, $this->pearErrorMode, E_USER_ERROR, __FILE__, __LINE__, 'No options specified!');
     }
     if (isset($options['mail_table'])) {
         $this->mail_table = $options['mail_table'];
         unset($options['mail_table']);
     }
     if (isset($options['sequence'])) {
         $this->sequence = $options['sequence'];
         unset($options['sequence']);
     } else {
         $this->sequence = $this->mail_table;
     }
     if (!empty($options['pearErrorMode'])) {
         $this->pearErrorMode = $options['pearErrorMode'];
     }
     if (isset($options['dsn'])) {
         $dsn = $options['dsn'];
     } else {
         $dsn = $options;
     }
     $this->db =& MDB::Connect($dsn);
     if (MDB::isError($this->db)) {
         return new Mail_Queue_Error(MAILQUEUE_ERROR_CANNOT_CONNECT, $this->pearErrorMode, E_USER_ERROR, __FILE__, __LINE__, 'MDB::connect failed: ' . $this->db->getMessage());
     } else {
         $this->db->setFetchMode(MDB_FETCHMODE_ASSOC);
     }
     $this->setOption();
 }