function query($query, $unbuffered = false) { $result = ibase_query($query, $this->_link); if (!$result) { $this->errno = ibase_errcode(); $this->error = ibase_errmsg(); return false; } $this->error = ""; if ($result === true) { $this->affected_rows = ibase_affected_rows($this->_link); return true; } return new Min_Result($result); }
/** * 数据库错误信息 * 并显示当前的SQL语句 * @access public * @return string */ public function error() { $this->error = ibase_errcode() . ':' . ibase_errmsg(); if ('' != $this->queryStr) { $this->error .= "\n [ SQL语句 ] : " . $this->queryStr; } trace($this->error, '', 'ERR'); return $this->error; }
public function errorCode() { return ibase_errcode($this->handler); }
/** * Error * * Returns an array containing code and message of the last * database error that has occured. * * @return array */ public function error() { return array('code' => ibase_errcode(), 'message' => ibase_errmsg()); }
/** * Devuelve el no error de Firebird * * @return int */ public function no_error() { return ibase_errcode(); }
function _setDbError($query) { return $this->_setLastError(ibase_errcode(), ibase_errmsg(), $query); }
/** * Fetches the row at current position and moves the internal cursor to the next position. * @param bool TRUE for associative array, FALSE for numeric * @return array array on success, nonarray if no next record */ public function fetch($assoc) { DibiDriverException::tryError(); $result = $assoc ? ibase_fetch_assoc($this->resultSet, IBASE_TEXT) : ibase_fetch_row($this->resultSet, IBASE_TEXT); // intentionally @ if (DibiDriverException::catchError($msg)) { if (ibase_errcode() == self::ERROR_EXCEPTION_THROWN) { preg_match('/exception (\\d+) (\\w+) (.*)/is', ibase_errmsg(), $match); throw new DibiProcedureException($match[3], $match[1], $match[2], dibi::$sql); } else { throw new DibiDriverException($msg, ibase_errcode(), dibi::$sql); } } return $result; }
<?php include "conexao.php"; $nome = $_POST["nome"]; $email = $_POST["email"]; $assunto = $_POST["assunto"]; $mensagem = $_POST["mensagem"]; $data = date("d.m.Y"); //echo " <br> <br> $nome $email $assunto $mensagem $data "; $consulta = ibase_query("INSERT INTO TB_MENSAGENS VALUES(1,'{$nome}','{$email}','{$assunto}', '{$mensagem}', '{$data}')"); if (ibase_affected_rows() > 0) { echo "\n <section id='about'>\n <div class='container'>\n\n <div class='section-header'>\n <h2 class='section-title text-center wow fadeInDown'>Mensagem Recebida</h2>\n <p class='text-center wow fadeInDown'>Responderemos o mais rápido possível</p>\n </div>\n </div>\n </section><!--/#about-->\n\n <div class='container' align='center'>\n <a class='btn btn-primary btn-block' href='index.html'>Voltar</a>\n </div>\n\n <br>\n <br>\n"; } else { ibase_errcode(); } ?> <section id="cta2"> <div class="container"> <div class="text-center"> <h2 class="wow fadeInUp" data-wow-duration="300ms" data-wow-delay="0ms"><span>EDUC Aluno</span> o App para consultas acadêmicas</h2> <p class="wow fadeInUp" data-wow-duration="300ms" data-wow-delay="100ms">Uma ferramenta fácil e prática para consultas academicas.</p> <p class="wow fadeInUp" data-wow-duration="300ms" data-wow-delay="200ms"><a class="btn btn-primary btn-lg" href="https://play.google.com/store/apps/details?id=br.tecsof.educ">Veja na Google Play</a></p> <img class="img-responsive wow fadeIn" src="images/cta2/cta2-img.png" alt="" data-wow-duration="300ms" data-wow-delay="300ms">
/** * Fetches a row from the result set. * * @param int $style OPTIONAL Fetch mode for this fetch operation. * @param int $cursor OPTIONAL Absolute, relative, or other. * @param int $offset OPTIONAL Number for absolute or relative cursors. * @return mixed Array, object, or scalar depending on fetch mode. * @throws Zend_Db_Statement_Exception */ public function fetch($style = null, $cursor = null, $offset = null) { if (!$this->_stmtResult) { return false; } if ($style === null) { $style = $this->_fetchMode; } switch ($style) { case Zend_Db::FETCH_NUM: $row = ibase_fetch_row($this->_stmtResult, IBASE_TEXT); break; case Zend_Db::FETCH_ASSOC: $row = ibase_fetch_assoc($this->_stmtResult, IBASE_TEXT); break; case Zend_Db::FETCH_BOTH: $row = ibase_fetch_assoc($this->_stmtResult, IBASE_TEXT); if ($row !== false) { $row = array_merge($row, array_values($row)); } break; case Zend_Db::FETCH_OBJ: $row = ibase_fetch_object($this->_stmtResult, IBASE_TEXT); break; case Zend_Db::FETCH_BOUND: $row = ibase_fetch_assoc($this->_stmtResult, IBASE_TEXT); if ($row !== false) { $row = array_merge($row, array_values($row)); $row = $this->_fetchBound($row); } break; default: /** * @see Zend_Db_Adapter_Firebird_Exception */ require_once 'Zend/Db/Statement/Firebird/Exception.php'; throw new Zend_Db_Statement_Firebird_Exception("Invalid fetch mode '{$style}' specified"); break; } if (!$row && ($error = ibase_errcode())) { /** * @see Zend_Db_Adapter_Firebird_Exception */ require_once 'Zend/Db/Statement/Firebird/Exception.php'; throw new Zend_Db_Statement_Firebird_Exception($error); } return $row; }
/** * Exécute une requète sur la base de données * * @param string $query * * @access public * @return mixed */ function query($query) { if ($this->_matchLimitOffset && preg_match('/\\s+LIMIT\\s+(\\d+)\\s+OFFSET\\s+(\\d+)\\s*$/i', $query, $match)) { $query = substr($query, 0, -strlen($match[0])); $query = substr($query, 6); $query = "SELECT FIRST {$match['1']} SKIP {$match['2']}" . $query; } $curtime = array_sum(explode(' ', microtime())); $result = ibase_query($this->link, $query); $endtime = array_sum(explode(' ', microtime())); $this->sqltime += $endtime - $curtime; $this->lastQuery = $query; $this->queries++; if (!$result) { $this->errno = ibase_errcode(); $this->error = ibase_errmsg(); $this->rollBack(); } else { $this->errno = 0; $this->error = ''; if (in_array(strtoupper(substr($query, 0, 6)), array('INSERT', 'UPDATE', 'DELETE')) && $this->autocommit) { ibase_commit($this->link); } if (!is_bool($result)) { // on a réceptionné une ressource ou un objet $result = new WadbResult_firebird($this->link, $result); } } return $result; }
/** * return sql error array * @access private */ function _sql_error() { // Need special handling here because ibase_errmsg returns // connection errors, however if the interbase extension // is not installed then ibase_errmsg does not exist and // we cannot call it. if (function_exists('ibase_errmsg')) { $msg = @ibase_errmsg(); if (!$msg) { $msg = $this->connect_error; } } else { $msg = $this->connect_error; } return array('message' => $msg, 'code' => @function_exists('ibase_errcode') ? @ibase_errcode() : ''); }
public function FBUpdate($tableName, $other_request, $exception, $str_where, $intDebug = 0) { $nfield = 0; $nother = 0; $nexception = count($exception); if ($this->isTableExist($tableName)) { $this->erro = 0; $this->erro_msg = ''; $this->rows = 0; if ($this->erro == 0) { $qry_temp = "UPDATE {$tableName} SET "; $sql = "select FIRST 1 SKIP 1 * from {$tableName} "; $intQuery = $this->Query($sql, 0, 1); $coln = $this->GetNumFields($intQuery); $this->setFieldTable($intQuery); for ($i = 0; $i < $coln; $i++) { $col_info = $this->GetFieldInfo($intQuery, $i); $col_info['name'] = strtolower($col_info['name']); if (!in_array($col_info['name'], array_change_key_case($exception, CASE_LOWER))) { if (array_key_exists($col_info['name'], $_REQUEST)) { $nfield++; if ($col_info['type'] == 'DATE') { if ($_REQUEST[$col_info['name']] == '') { $qry_temp .= $col_info['name'] . '=NULL,'; } else { $qry_temp .= $col_info['name'] . '=' . $this->quote_smart($this->formatDate($_REQUEST[$col_info['name']])) . ','; } } elseif (!in_array($col_info['type'], $this->type_string)) { $qry_temp .= $col_info['name'] . '=' . $this->quote_smart(str_replace(',', '', $_REQUEST[$col_info['name']])) . ','; } else { $qry_temp .= $col_info['name'] . '=' . $this->quote_smart($_REQUEST[$col_info['name']]) . ','; } } if (array_key_exists(strtolower($col_info['name']), array_change_key_case($other_request, CASE_LOWER))) { $nother++; if ($col_info['type'] == 'DATE') { if ($other_request[$col_info['name']] == '') { $qry_temp .= $col_info['name'] . '=NULL,'; } else { $qry_temp .= $col_info['name'] . '=' . $this->quote_smart($this->formatDate($other_request[$col_info['name']])) . ','; } } elseif (!in_array($col_info['type'], $this->type_string)) { $qry_temp .= $col_info['name'] . '=' . $this->quote_smart(str_replace(',', '', $other_request[$col_info['name']])) . ','; } else { $qry_temp .= $col_info['name'] . '=' . $this->quote_smart($other_request[$col_info['name']]) . ','; } } if ($col_info['type'] == 'TIMESTAMP') { $qry_temp .= $col_info['name'] . '=' . $this->quote_smart('NOW') . ','; $nfield++; } if ($col_info['name'] == 'user_id') { $qry_temp .= $col_info['name'] . '=' . $this->quote_smart(b_getuserlogin()) . ','; $nfield++; } } } $qry_temp .= ')'; $qry_temp = str_replace(',)', ' ', $qry_temp); $qry_temp .= ' ' . $str_where . ' '; if ($intDebug) { echo $qry_temp; } else { if ($coln - $nexception != $nfield + $nother) { echo '$coln: ' . $coln . "\n"; echo '$nexception: ' . $nexception . "\n"; echo '$nfield: ' . $nfield . "\n"; echo '$nother: ' . $nother . "\n"; echo 'Parameter Query Invalid' . "\n"; } else { //$this->result=@$this->Query($qry_temp,0,1); $this->result = ibase_query($qry_temp); if ($this->result) { $this->erro = 0; $this->erro_msg = 'Executing Insert Query Success !'; } else { $this->erro = ibase_errcode(); $this->erro_msg = ibase_errmsg(); } } } } } else { $this->erro = 99; $this->erro_msg = 'Table doesn\'t exist !'; } return $this->result; }
/** * Prepare * * @param string $sql * @throws Exception\InvalidQueryException * @throws Exception\RuntimeException * @return Statement */ public function prepare($sql = null) { if ($this->isPrepared) { throw new Exception\RuntimeException('This statement has already been prepared'); } $sql = $sql ?: $this->sql; $this->resource = ibase_prepare($sql); if ($this->resource === false) { throw new Exception\RuntimeException(ibase_errmsg(), ibase_errcode()); } $this->isPrepared = true; return $this; }
/** * Error. * * Returns an array containing code and message of the last * database error that has occured. * * @return array */ public function error() { return ['code' => ibase_errcode(), 'message' => ibase_errmsg()]; }
/** *@package db_firebird *@method query() *@desc Send a Firebird/Interbase query *@since v0.3.1 *@return bool & Populates $this->resource * */ public function query($query) { $this->sql_query = $query; if ($this->resource = ibase_query($query)) { return TRUE; } else { // is hanled error $error_no = ibase_errcode(); $is_handed = false; if (array_key_exists($error_no, $this->arr_handled_errors)) { $is_handed = true; } if ($is_handed == true) { $this->error_code = $this->arr_handled_errors[$error_no]; return FALSE; } else { // if uknown error try { throw new FkException("Firebird/Interbase Error"); } catch (FkException $e) { $e->description = 'Firebird/Interbase Respondió:' . ibase_errmsg() . '</b>'; $e->solution = 'Verifique la consulta'; $e->solution_code = fk_str_format($query, 'html'); $e->error_code = $error_no; $e->show('code_help'); } return FALSE; } } // End else }
/** * return sql error array * @access private */ function _sql_error() { return array('message' => @ibase_errmsg(), 'code' => @function_exists('ibase_errcode') ? @ibase_errcode() : ''); }
/** * Gets the last error code associated with the last operation. * @return string The last error code associated with the last operation. */ public function errorCode() { return ibase_errcode(); }
/** * Fetches a row from the result set. * * @param int $style OPTIONAL Fetch mode for this fetch operation. * @param int $cursor OPTIONAL Absolute, relative, or other. * @param int $offset OPTIONAL Number for absolute or relative cursors. * @return mixed Array, object, or scalar depending on fetch mode. * @throws Zend_Db_Statement_Exception */ public function fetch($style = null, $cursor = null, $offset = null) { if (!$this->_stmt_result) { return false; } if ($style === null) { $style = $this->_fetchMode; } // @todo, respect the foldCase for column names switch ($style) { case Zend_Db::FETCH_NUM: $row = ibase_fetch_row($this->_stmt_result, IBASE_TEXT); break; case Zend_Db::FETCH_ASSOC: $row = ibase_fetch_assoc($this->_stmt_result, IBASE_TEXT); break; case Zend_Db::FETCH_BOTH: $row = ibase_fetch_assoc($this->_stmt_result, IBASE_TEXT); $values = array_values($row); foreach ($values as $val) { $row[] = $val; } break; case Zend_Db::FETCH_OBJ: $row = ibase_fetch_object($this->_stmt_result, IBASE_TEXT); break; case Zend_Db::FETCH_BOUND: $row = ibase_fetch_assoc($this->_stmt_result, IBASE_TEXT); $values = array_values($row); foreach ($values as $val) { $row[] = $val; } if ($row !== false) { return $this->_fetchBound($row); } break; default: /** * @see Zend_Db_Adapter_Firebird_Exception */ require_once 'Zend/Db/Statement/Firebird/Exception.php'; throw new Zend_Db_Statement_Firebird_Exception("Invalid fetch mode '{$style}' specified"); break; } if (!$row && ($error = ibase_errcode())) { /** * @see Zend_Db_Adapter_Firebird_Exception */ require_once 'Zend/Db/Statement/Firebird/Exception.php'; throw new Zend_Db_Statement_Firebird_Exception($error); } /* switch ($this->_adapter->caseFolding) { case Zend_Db::CASE_LOWER: $r = array_change_key_case($row, CASE_LOWER); break; case Zend_Db::CASE_UPPER: $r = array_change_key_case($row, CASE_UPPER); break; case default: $r = $row; break; }*/ return $row; }
/** * Fetches the row at current position and moves the internal cursor to the next position. * @param bool TRUE for associative array, FALSE for numeric * @return array array on success, nonarray if no next record */ public function fetch($assoc) { $result = $assoc ? @ibase_fetch_assoc($this->resultSet, IBASE_TEXT) : @ibase_fetch_row($this->resultSet, IBASE_TEXT); // intentionally @ if (ibase_errcode()) { if (ibase_errcode() == self::ERROR_EXCEPTION_THROWN) { preg_match('/exception (\\d+) (\\w+) (.*)/is', ibase_errmsg(), $match); throw new Dibi\ProcedureException($match[3], $match[1], $match[2]); } else { throw new Dibi\DriverException(ibase_errmsg(), ibase_errcode()); } } return $result; }
/** * Retrieves an array of error information, if any, associated with the * last operation on the statement handle. * * @return array */ public function errorInfo() { if (!$this->_stmtPrepared) { return false; } return array(ibase_errcode(), ibase_errmsg()); }
/** * The error message number * * @access private * @return integer */ function _error_number() { if (($error = ibase_errcode()) == FALSE) { return 0; } return $error; }
/** * This method is used to collect information about an error * * @param integer $error * @return array * @access public */ function errorInfo($error = null) { $native_msg = @ibase_errmsg(); if (function_exists('ibase_errcode')) { $native_code = @ibase_errcode(); } else { // memo for the interbase php module hackers: we need something similar // to mysql_errno() to retrieve error codes instead of this ugly hack if (preg_match('/^([^0-9\\-]+)([0-9\\-]+)\\s+(.*)$/', $native_msg, $m)) { $native_code = (int) $m[2]; } else { $native_code = null; } } if (null === $error) { $error = MDB2_ERROR; if ($native_code) { // try to interpret Interbase error code (that's why we need ibase_errno() // in the interbase module to return the real error code) switch ($native_code) { case -204: if (isset($m[3]) && is_int(strpos($m[3], 'Table unknown'))) { $errno = MDB2_ERROR_NOSUCHTABLE; } break; default: static $ecode_map; if (empty($ecode_map)) { $ecode_map = array(-104 => MDB2_ERROR_SYNTAX, -150 => MDB2_ERROR_ACCESS_VIOLATION, -151 => MDB2_ERROR_ACCESS_VIOLATION, -155 => MDB2_ERROR_NOSUCHTABLE, -157 => MDB2_ERROR_NOSUCHFIELD, -158 => MDB2_ERROR_VALUE_COUNT_ON_ROW, -170 => MDB2_ERROR_MISMATCH, -171 => MDB2_ERROR_MISMATCH, -172 => MDB2_ERROR_INVALID, -205 => MDB2_ERROR_NOSUCHFIELD, -206 => MDB2_ERROR_NOSUCHFIELD, -208 => MDB2_ERROR_INVALID, -219 => MDB2_ERROR_NOSUCHTABLE, -297 => MDB2_ERROR_CONSTRAINT, -303 => MDB2_ERROR_INVALID, -413 => MDB2_ERROR_INVALID_NUMBER, -530 => MDB2_ERROR_CONSTRAINT, -551 => MDB2_ERROR_ACCESS_VIOLATION, -552 => MDB2_ERROR_ACCESS_VIOLATION, -625 => MDB2_ERROR_CONSTRAINT_NOT_NULL, -803 => MDB2_ERROR_CONSTRAINT, -804 => MDB2_ERROR_VALUE_COUNT_ON_ROW, -904 => MDB2_ERROR_CONNECT_FAILED, -922 => MDB2_ERROR_NOSUCHDB, -923 => MDB2_ERROR_CONNECT_FAILED, -924 => MDB2_ERROR_CONNECT_FAILED); } if (isset($ecode_map[$native_code])) { $error = $ecode_map[$native_code]; } break; } } else { static $error_regexps; if (!isset($error_regexps)) { $error_regexps = array('/generator .* is not defined/' => MDB2_ERROR_SYNTAX, '/table.*(not exist|not found|unknown)/i' => MDB2_ERROR_NOSUCHTABLE, '/table .* already exists/i' => MDB2_ERROR_ALREADY_EXISTS, '/unsuccessful metadata update .* failed attempt to store duplicate value/i' => MDB2_ERROR_ALREADY_EXISTS, '/unsuccessful metadata update .* not found/i' => MDB2_ERROR_NOT_FOUND, '/validation error for column .* value "\\*\\*\\* null/i' => MDB2_ERROR_CONSTRAINT_NOT_NULL, '/violation of [\\w ]+ constraint/i' => MDB2_ERROR_CONSTRAINT, '/conversion error from string/i' => MDB2_ERROR_INVALID_NUMBER, '/no permission for/i' => MDB2_ERROR_ACCESS_VIOLATION, '/arithmetic exception, numeric overflow, or string truncation/i' => MDB2_ERROR_INVALID, '/feature is not supported/i' => MDB2_ERROR_NOT_CAPABLE); } foreach ($error_regexps as $regexp => $code) { if (preg_match($regexp, $native_msg, $m)) { $error = $code; break; } } } } return array($error, $native_code, $native_msg); }
/** * @brief : 쿼리문의 실행 및 결과의 fetch 처리 * * query : query문 실행하고 result return\n * fetch : reutrn 된 값이 없으면 NULL\n * rows이면 array object\n * row이면 object\n * return\n **/ function _query($query, $params = null) { if (!$this->isConnected()) { return; } if (count($params) == 0) { // 쿼리 시작을 알림 $this->actStart($query); // 쿼리 문 실행 $result = ibase_query($this->fd, $query); } else { // 쿼리 시작을 알림 $log = $query . "\n\t\t\t"; $log .= implode(",", $params); $this->actStart($log); // 쿼리 문 실행 (blob type 입력하기 위한 방법) $query = ibase_prepare($this->fd, $query); $fnarr = array_merge(array($query), $params); $result = call_user_func_array("ibase_execute", $fnarr); } // 오류 체크 if (ibase_errmsg()) { $this->setError(ibase_errcode(), ibase_errmsg()); } // 쿼리 실행 종료를 알림 $this->actFinish(); // 결과 리턴 return $result; }
/** * Execute any statement * * @param string sql * @param bool buffered default TRUE * @return rdbms.ResultSet * @throws rdbms.SQLException */ protected function query0($sql, $buffered = true) { if (!is_resource($this->handle)) { if (!($this->flags & DB_AUTOCONNECT)) { throw new \rdbms\SQLStateException('Not connected'); } $c = $this->connect(); // Check for subsequent connection errors if (false === $c) { throw new \rdbms\SQLStateException('Previously failed to connect'); } } $result = ibase_query($sql, $this->handle); if (false === $result) { $message = 'Statement failed: ' . trim(ibase_errmsg()) . ' @ ' . $this->dsn->getHost(); $code = ibase_errcode(); switch ($code) { case -924: // Connection lost throw new \rdbms\SQLConnectionClosedException($message, $sql); case -913: // Deadlock throw new \rdbms\SQLDeadlockException($message, $sql, $code); default: // Other error throw new \rdbms\SQLStatementFailedException($message, $sql, $code); } } else { if (true === $result) { return new QuerySucceeded(ibase_affected_rows($this->handle)); } else { return new InterBaseResultSet($result, $this->tz); } } }
/** * Creates a connection to the database. * * @return void * @throws Zend_Db_Adapter_Firebird_Exception */ protected function _connect() { if (is_resource($this->_connection)) { return; } if (!extension_loaded('interbase')) { /** * @see Zend_Db_Adapter_Firebird_Exception */ require_once 'Zend/Db/Adapter/Firebird/Exception.php'; throw new Zend_Db_Adapter_Firebird_Exception('The Interbase extension is required for this adapter but the extension is not loaded'); } $port = ''; if (isset($this->_config['port'])) { $port = '/' . (int) $this->_config['port']; } // Suppress connection warnings here. // Throw an exception instead. @($this->_connection = @ibase_connect($this->_config['host'] . $port . ':' . $this->_config['dbname'], $this->_config['username'], $this->_config['password'], $this->_config['charset'], $this->_config['buffers'], $this->_config['dialect'], $this->_config['role'])); if ($this->_connection === false || ibase_errcode()) { /** * @see Zend_Db_Adapter_Firebird_Exception */ require_once 'Zend/Db/Adapter/Firebird/Exception.php'; throw new Zend_Db_Adapter_Firebird_Exception(ibase_errmsg()); } }
/** * Gets the DBMS' native error code produced by the last query * * @return int the DBMS' error code. NULL if there is no error code. * * @since Method available since Release 1.7.0 */ function errorNative() { if (function_exists('ibase_errcode')) { return @ibase_errcode(); } if (preg_match('/^Dynamic SQL Error SQL error code = ([0-9-]+)/i', @ibase_errmsg(), $m)) { return (int) $m[1]; } return null; }
/** * The error message number * * @access private * @return integer */ function _error_number() { return ibase_errcode(); }