/**
  * returns last error message or false if no errors occurred
  *
  * @param PMA_DrizzleCon $link connection object
  *
  * @return string|bool $error or false
  */
 public function getError($link)
 {
     $GLOBALS['errno'] = 0;
     if (null !== $link && false !== $link) {
         $error_number = drizzle_con_errno($link->getConnectionObject());
         $error_message = drizzle_con_error($link->getConnectionObject());
     } else {
         $error_number = drizzle_errno();
         $error_message = drizzle_error();
     }
     if (0 == $error_number) {
         return false;
     }
     // keep the error number for further check after
     // the call to getError()
     $GLOBALS['errno'] = $error_number;
     return $GLOBALS['dbi']->formatError($error_number, $error_message);
 }
示例#2
0
/**
 * returns last error message or false if no errors occured
 *
 * @param   PMA_DrizzleCon  $link  connection object
 * @return  string|bool  $error or false
 */
function PMA_DBI_getError($link = null)
{
    $GLOBALS['errno'] = 0;
    /* Treat false same as null because of controllink */
    if ($link === false) {
        $link = null;
    }
    if (null === $link && isset($GLOBALS['userlink'])) {
        $link =& $GLOBALS['userlink'];
        // Do not stop now. We still can get the error code
        // with mysqli_connect_errno()
        //    } else {
        //        return false;
    }
    if (null !== $link) {
        $error_number = drizzle_con_errno($link->getConnectionObject());
        $error_message = drizzle_con_error($link->getConnectionObject());
    } else {
        $error_number = drizzle_errno();
        $error_message = drizzle_error();
    }
    if (0 == $error_number) {
        return false;
    }
    // keep the error number for further check after the call to PMA_DBI_getError()
    $GLOBALS['errno'] = $error_number;
    return PMA_DBI_formatError($error_number, $error_message);
}
示例#3
0
 /**
  * This function opens a connection using the data source provided.
  *
  * @access public
  * @override
  * @throws Throwable_Database_Exception         indicates that there is problem with
  *                                              opening the connection
  *
  * @see http://wiki.drizzle.org/MySQL_Differences
  */
 public function open()
 {
     if (!$this->is_connected()) {
         $handle = drizzle_create();
         $host = $this->data_source->host;
         $port = $this->data_source->port;
         $database = $this->data_source->database;
         $username = $this->data_source->username;
         $password = $this->data_source->password;
         $this->resource = @drizzle_con_add_tcp($handle, $host, $port, $username, $password, $database, 0);
         if ($this->resource === FALSE) {
             throw new Throwable_Database_Exception('Message: Failed to establish connection. Reason: :reason', array(':reason' => @drizzle_error($handle)));
         }
         // "There is no CHARSET or CHARACTER SET commands, everything defaults to UTF-8."
     }
 }