Exemplo n.º 1
1
 public function query($sql)
 {
     LogMaster::log($sql);
     $res = sasql_query($this->connection, $sql);
     if ($res === false) {
         throw new Exception("SaSQL operation failed\n" . sasql_error($this->connection));
     }
     $this->last_result = $res;
     return $res;
 }
 /**
  * Helper method to turn SQL Anywhere error into exception.
  *
  * @param resource|null $conn The SQL Anywhere connection resource to retrieve the last error from.
  * @param resource|null $stmt The SQL Anywhere statement resource to retrieve the last error from.
  *
  * @return SQLAnywhereException
  *
  * @throws \InvalidArgumentException
  */
 public static function fromSQLAnywhereError($conn = null, $stmt = null)
 {
     if (null !== $conn && !(is_resource($conn) && get_resource_type($conn) === 'SQLAnywhere connection')) {
         throw new \InvalidArgumentException('Invalid SQL Anywhere connection resource given: ' . $conn);
     }
     if (null !== $stmt && !(is_resource($stmt) && get_resource_type($stmt) === 'SQLAnywhere statement')) {
         throw new \InvalidArgumentException('Invalid SQL Anywhere statement resource given: ' . $stmt);
     }
     $state = $conn ? sasql_sqlstate($conn) : sasql_sqlstate();
     $code = null;
     $message = null;
     /**
      * Try retrieving the last error from statement resource if given
      */
     if ($stmt) {
         $code = sasql_stmt_errno($stmt);
         $message = sasql_stmt_error($stmt);
     }
     /**
      * Try retrieving the last error from the connection resource
      * if either the statement resource is not given or the statement
      * resource is given but the last error could not be retrieved from it (fallback).
      * Depending on the type of error, it is sometimes necessary to retrieve
      * it from the connection resource even though it occurred during
      * a prepared statement.
      */
     if ($conn && !$code) {
         $code = sasql_errorcode($conn);
         $message = sasql_error($conn);
     }
     /**
      * Fallback mode if either no connection resource is given
      * or the last error could not be retrieved from the given
      * connection / statement resource.
      */
     if (!$conn || !$code) {
         $code = sasql_errorcode();
         $message = sasql_error();
     }
     if ($message) {
         return new self('SQLSTATE [' . $state . '] [' . $code . '] ' . $message, $state, $code);
     }
     return new self('SQL Anywhere error occurred but no error message was retrieved from driver.', $state, $code);
 }
 public function __setErrors($er)
 {
     if (!is_resource($this->__connection)) {
         $errno = sasql_errorcode();
         $errst = sasql_error();
     } else {
         $errno = sasql_errorcode($this->__connection);
         $errst = sasql_error($this->__connection);
     }
     $this->__errorCode =& $er;
     $this->__errorInfo = array($this->__errorCode, $errno, $errst);
     $this->__result = false;
 }
 /**
  * Returns all error info for connection
  * @return [type] [description]
  */
 public function errorInfo()
 {
     return sasql_error($this->connection ? $this->connection : null);
 }
Exemplo n.º 5
0
 /**
  * The error message string
  *
  * @access	private
  * @return	string
  */
 function _error_message()
 {
     return sasql_error($this->conn_id);
 }
Exemplo n.º 6
0
 /**
  * Get the most recent error message.
  */
 function db_error()
 {
     return sasql_error();
 }