Exemple #1
0
 /**
  * Create a FUNCTION
  */
 public function createFunction($name)
 {
     return $this->db->raiseError(MDB2_ERROR_NOT_CAPABLE, null, null, 'not capable', __FUNCTION__);
 }
Exemple #2
0
 /**
  * Create a new MDB2 connection object and connect to the specified
  * database
  *
  * IMPORTANT: In order for MDB2 to work properly it is necessary that
  * you make sure that you work with a reference of the original
  * object instead of a copy (this is a PHP4 quirk).
  *
  * For example:
  *     $mdb =& MDB2::connect($dsn);
  *          ^^
  * And not:
  *     $mdb = MDB2::connect($dsn);
  *          ^^
  *
  * @param   mixed   $dsn      'data source name', see the MDB2::parseDSN
  *                            method for a description of the dsn format.
  *                            Can also be specified as an array of the
  *                            format returned by MDB2::parseDSN.
  * @param   array   $options  An associative array of option names and
  *                            their values.
  * @return  mixed   a newly created MDB2 connection object, or a MDB2
  *                  error object on error
  * @access  public
  * @see     MDB2::parseDSN
  */
 function &connect($dsn, $options = false)
 {
     $dsninfo = MDB2::parseDSN($dsn);
     if (!isset($dsninfo['phptype'])) {
         $error =& MDB2_Driver_Common::raiseError(MDB2_ERROR_NOT_FOUND, null, null, 'no RDBMS driver specified');
         return $error;
     }
     $type = $dsninfo['phptype'];
     if (is_array($options) && isset($options['debug']) && $options['debug'] >= 2) {
         $debug = true;
     } else {
         $debug = false;
     }
     $db =& MDB2::factory($type, $debug);
     if (MDB2::isError($db)) {
         return $db;
     }
     $db->setDSN($dsninfo);
     $err = MDB2::setOptions($db, $options);
     if (MDB2::isError($err)) {
         $db->disconnect();
         return $err;
     }
     if (isset($dsninfo['database'])) {
         $err = $db->connect();
         if (MDB2::isError($err)) {
             $dsn = $db->getDSN();
             $err->addUserInfo($dsn);
             return $err;
         }
     }
     return $db;
 }
 /**
  * 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)
 {
     $error =& MDB2_Driver_Common::raiseError($code, $mode, $options, $userinfo);
     return $error;
 }
 function raiseError($msg, $xp = null)
 {
     if (is_null($this->error)) {
         if (is_resource($msg)) {
             $error = "Parser error: ";
             $xp = $msg;
         } else {
             $error = "Parser error: \"" . $msg . "\"\n";
         }
         if ($xp != null) {
             $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}\n";
         }
         $this->error = MDB2_Driver_Common::raiseError(MDB2_ERROR_MANAGER_PARSE, null, null);
     }
     return false;
 }
Exemple #5
0
 /**
  * Returns the autoincrement ID if supported or $id or fetches the current
  * ID in a sequence called: $table.(empty($field) ? '' : '_'.$field)
  *
  * @param   string  name of the table into which a new row was inserted
  * @param   string  name of the field into which a new row was inserted
  *
  * @return  mixed   MDB2 Error Object or id
  */
 public function lastInsertID($table = null, $field = null)
 {
     return MDB2_Driver_Common::raiseError(MDB2_ERROR_UNSUPPORTED, null, null, 'method not implemented', __FUNCTION__);
 }
Exemple #6
0
 function readLOB(&$data, $length)
 {
     $buffer_length = $length == 0 ? $this->buffer_length : $length;
     $written_full = 0;
     do {
         for ($written = 0; !$this->db->datatype->endOfLOB($this->input_lob) && $written < $buffer_length; $written += $read) {
             $result = $this->db->datatype->readLOB($this->input_lob, $buffer, $buffer_length);
             if (MDB2::isError($result)) {
                 return $result;
             }
             $read = strlen($buffer);
             if (@fwrite($this->file, $buffer, $read) != $read) {
                 return MDB2_Driver_Common::raiseError(MDB2_ERROR, null, null, 'MDB2_LOB_Output_File::readLOB: could not write to the output file');
             }
         }
         $written_full += $written;
     } while ($length == 0 && !$this->db->datatype->endOfLOB($this->input_lob));
     return $written_full;
 }