Exemple #1
0
 /**
  * Get the instance of MDB2 associated with the module instance
  *
  * @return  object  MDB2 instance or a MDB2 error on failure
  *
  * @access  public
  */
 function getDBInstance()
 {
     if (isset($GLOBALS['_MDB2_databases'][$this->db_index])) {
         $result = $GLOBALS['_MDB2_databases'][$this->db_index];
     } else {
         $result = MDB2::raiseError(MDB2_ERROR_NOT_FOUND, null, null, 'could not find MDB2 instance');
     }
     return $result;
 }
Exemple #2
0
     */
    function stream_stat()
    {
        if (isset($GLOBALS['_MDB2_databases'][$this->db_index])) {
            $db =& $GLOBALS['_MDB2_databases'][$this->db_index];
            return array('db_index' => $this->db_index, 'lob_index' => $this->lob_index);
        }
    }
    // }}}
    // {{{ stream_close()
    /**
     * close stream
     *
     * @access public
     */
    function stream_close()
    {
        if (isset($GLOBALS['_MDB2_databases'][$this->db_index])) {
            $db =& $GLOBALS['_MDB2_databases'][$this->db_index];
            if (isset($db->datatype->lobs[$this->lob_index])) {
                $db->datatype->_destroyLOB($db->datatype->lobs[$this->lob_index]);
                unset($db->datatype->lobs[$this->lob_index]);
            }
        }
    }
}
// register streams wrapper
if (!stream_wrapper_register("MDB2LOB", "MDB2_LOB")) {
    MDB2::raiseError();
    return false;
}
Exemple #3
0
 /**
  * This method is used to communicate an error and invoke error
  * callbacks etc.  Basically a wrapper for PEAR::raiseError
  * without the message string.
  *
  * @param mixed    integer error code, or a PEAR error object (all
  *                 other parameters are ignored if this parameter is
  *                 an object
  *
  * @param int      error mode, see PEAR_Error docs
  *
  * @param mixed    If error mode is PEAR_ERROR_TRIGGER, this is the
  *                 error level (E_USER_NOTICE etc).  If error mode is
  *                 PEAR_ERROR_CALLBACK, this is the callback function,
  *                 either as a function name, or as an array of an
  *                 object and method name.  For other error modes this
  *                 parameter is ignored.
  *
  * @param string   Extra debug information.  Defaults to the last
  *                 query and native error code.
  *
  * @return object  a PEAR error object
  *
  * @see PEAR_Error
  */
 function &raiseError($code = null, $mode = null, $options = null, $userinfo = null)
 {
     // The error is yet a MDB2 error object
     if (PEAR::isError($code)) {
         // because we use the static PEAR::raiseError, our global
         // handler should be used if it is set
         if (is_null($mode) && !empty($this->_default_error_mode)) {
             $mode = $this->_default_error_mode;
             $options = $this->_default_error_options;
         }
         return MDB2::raiseError($code, $mode, $options);
     }
     if (is_null($userinfo) && isset($this->connection)) {
         if (!empty($this->last_query)) {
             $userinfo = "[Last query: {$this->last_query}]\n";
         }
         $native_errno = $native_msg = null;
         list($code, $native_errno, $native_msg) = $this->errorInfo($code);
         if (!is_null($native_errno)) {
             $userinfo .= "[Native code: {$native_errno}]\n";
         }
         if (!is_null($native_msg)) {
             $userinfo .= "[Native message: " . strip_tags($native_msg) . "]\n";
         }
     } else {
         $userinfo = "[Error message: {$userinfo}]\n";
     }
     return MDB2::raiseError($code, $mode, $options, $userinfo);
 }
Exemple #4
0
 /**
  * This method is used to communicate an error and invoke error
  * callbacks etc.  Basically a wrapper for PEAR::raiseError
  * without the message string.
  *
  * @param mixed $code integer error code, or a PEAR error object (all
  *      other parameters are ignored if this parameter is an object
  * @param int $mode error mode, see PEAR_Error docs
  * @param mixed $options If error mode is PEAR_ERROR_TRIGGER, this is the
  *      error level (E_USER_NOTICE etc).  If error mode is
  *      PEAR_ERROR_CALLBACK, this is the callback function, either as a
  *      function name, or as an array of an object and method name. For
  *      other error modes this parameter is ignored.
  * @param string $userinfo Extra debug information.  Defaults to the last
  *      query and native error code.
  * @param mixed $nativecode Native error code, integer or string depending
  *      the backend.
  * @return object a PEAR error object
  * @access public
  * @see PEAR_Error
  */
 function &raiseError($code = null, $mode = null, $options = null, $userinfo = null)
 {
     return MDB2::raiseError($code, $mode, $options, $userinfo);
 }
Exemple #5
0
 /**
  * retrieve LOB from the database
  *
  * @param resource $lob stream handle
  * @param string $file name of the file into which the LOb should be fetched
  * @return mixed MDB2_OK on success, a MDB2 error on failure
  * @access protected
  */
 function writeLOBToFile($lob, $file)
 {
     $db =& $GLOBALS['_MDB2_databases'][$this->db_index];
     $fp = fopen($file, 'wb');
     while (!feof($lob)) {
         $result = fread($lob, $db->options['lob_buffer_length']);
         $read = strlen($result);
         if (fwrite($fp, $result, $read) != $read) {
             fclose($fp);
             return MDB2::raiseError(MDB2_ERROR, null, null, 'writeLOBToFile: could not write to the output file');
         }
     }
     fclose($fp);
     return MDB2_OK;
 }
Exemple #6
0
 function raiseError($msg = null, $ecode = 0, $xp = null)
 {
     if (is_null($this->error)) {
         $error = '';
         if (is_resource($msg)) {
             $error .= 'Parser error: ' . xml_error_string(xml_get_error_code($msg));
             $xp = $msg;
         } else {
             $error .= 'Parser error: ' . $msg;
             if (!is_resource($xp)) {
                 $xp = $this->parser;
             }
         }
         if ($error_string = xml_error_string($ecode)) {
             $error .= ' - ' . $error_string;
         }
         if (is_resource($xp)) {
             $byte = @xml_get_current_byte_index($xp);
             $line = @xml_get_current_line_number($xp);
             $column = @xml_get_current_column_number($xp);
             $error .= " - Byte: {$byte}; Line: {$line}; Col: {$column}";
         }
         $error .= "\n";
         $this->error = MDB2::raiseError(MDB2_ERROR_MANAGER_PARSE, null, null, $error);
     }
     return $this->error;
 }