1
0
mirror of https://github.com/php/doc-ru.git synced 2026-04-24 07:48:05 +02:00
Files
archived-doc-ru/reference/oci8/functions/oci-error.xml
T
Sergey Panteleev 6d43fd64d7 Исправление форматирования
[skip-spellcheck]
[skip-lint]
2022-12-27 03:42:36 +03:00

200 lines
6.0 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<!-- EN-Revision: ed6de1ae20ce16c0c7be0b3fef282b6065bebfac Maintainer: shein Status: ready -->
<!-- Reviewed: no -->
<refentry xml:id="function.oci-error" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
<refname>oci_error</refname>
<refpurpose>Возвращает последнюю ошибку</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type class="union"><type>array</type><type>false</type></type><methodname>oci_error</methodname>
<methodparam choice="opt"><type class="union"><type>resource</type><type>null</type></type><parameter>connection_or_statement</parameter><initializer>&null;</initializer></methodparam>
</methodsynopsis>
<para>
Возвращает последнюю найденную ошибку.
</para>
<para>
Функция должна вызваться сразу же после появления ошибки.
Ошибки очищаются при произведении правильного запроса.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>connection_or_statement</parameter></term>
<listitem>
<para>
Для большинства ошибок параметром <parameter>connection_or_statement</parameter> является
соответствующий идентификатор соединения или выражения. Для ошибок во время
выполнения функций <function>oci_connect</function>,
<function>oci_new_connect</function> или <function>oci_pconnect</function>
следует передавать &null;.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
Если ошибок не найдено, то <function>oci_error</function> возвращает
&false;. В противном случае, <function>oci_error</function> возвращает
информацию об ошибке в виде ассоциативного массива.
</para>
<para>
<table>
<title>Описание массива вывода <function>oci_error</function></title>
<tgroup cols="3">
<thead>
<row>
<entry>Ключ массива</entry>
<entry>Тип</entry>
<entry>&Description;</entry>
</row>
</thead>
<tbody>
<row>
<entry><literal>code</literal></entry>
<entry><type>int</type></entry>
<entry>
Номер ошибки Oracle.
</entry>
</row>
<row>
<entry><literal>message</literal></entry>
<entry><type>string</type></entry>
<entry>
Текст ошибки Oracle.
</entry>
</row>
<row>
<entry><literal>offset</literal></entry>
<entry><type>int</type></entry>
<entry>
Позиция ошибки в запросе SQL. Если нет запроса, то равна
<literal>0</literal>
</entry>
</row>
<row>
<entry><literal>sqltext</literal></entry>
<entry><type>string</type></entry>
<entry>
Текст запроса SQL. Если нет запроса, то строка пуста.
</entry>
</row>
</tbody>
</tgroup>
</table>
</para>
</refsect1>
<refsect1 role="changelog">
&reftitle.changelog;
<informaltable>
<tgroup cols="2">
<thead>
<row>
<entry>&Version;</entry>
<entry>&Description;</entry>
</row>
</thead>
<tbody>
<row>
<entry>8.0.0, PECL OCI8 3.0.0</entry>
<entry>
<parameter>connection_or_statement</parameter> теперь допускает значение null.
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>Вывод сообщения об ошибке Oracle после ошибки соединения</title>
<programlisting role="php">
<![CDATA[
<?php
$conn = oci_connect("hr", "welcome", "localhost/XE");
if (!$conn) {
$e = oci_error(); // Для обработки ошибок oci_connect
trigger_error(htmlentities($e['message']), E_USER_ERROR);
}
?>
]]>
</programlisting>
</example>
</para>
<para>
<example>
<title>Вывод сообщения об ошибке Oracle после ошибки разбора</title>
<programlisting role="php">
<![CDATA[
<?php
$stid = oci_parse($conn, "select ' from dual"); // пропущенные кавычки
if (!$stid) {
$e = oci_error($conn); // Для обработки ошибок oci_parse
trigger_error(htmlentities($e['message']), E_USER_ERROR);
}
?>
]]>
</programlisting>
</example>
</para>
<para>
<example>
<title>Вывод сообщения об ошибке Oracle, ошибочного запроса и
позиции ошибки запуска запроса</title>
<programlisting role="php">
<![CDATA[
<?php
$stid = oci_parse($conn, "select does_not_exist from dual");
$r = oci_execute($stid);
if (!$r) {
$e = oci_error($stid); // Для обработки ошибок oci_execute
print htmlentities($e['message']);
print "\n<pre>\n";
print htmlentities($e['sqltext']);
printf("\n%".($e['offset']+1)."s", "^");
print "\n</pre>\n";
}
?>
]]>
</programlisting>
</example>
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->