git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@290889 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Christopher Jones 2009-11-17 22:23:22 +00:00
parent 810cf8cd0a
commit b7ed01a76b

View file

@ -3,7 +3,7 @@
<refentry xml:id="function.oci-statement-type" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
<refname>oci_statement_type</refname>
<refpurpose>Returns the type of an OCI statement</refpurpose>
<refpurpose>Returns the type of a statement</refpurpose>
</refnamediv>
<refsect1 role="description">
@ -13,7 +13,8 @@
<methodparam><type>resource</type><parameter>statement</parameter></methodparam>
</methodsynopsis>
<para>
Returns the type of the provided OCI <parameter>statement</parameter>.
Returns a keyword identifying the type of the
OCI8 <parameter>statement</parameter>.
</para>
</refsect1>
@ -25,7 +26,7 @@
<term><parameter>statement</parameter></term>
<listitem>
<para>
A valid OCI statement identifier.
A valid OCI8 statement identifier from <function>oci_parse</function>.
</para>
</listitem>
</varlistentry>
@ -36,22 +37,67 @@
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
Returns the query type of<parameter>statement</parameter> as one of the
following values:
<orderedlist>
<listitem><simpara><literal>SELECT</literal></simpara></listitem>
<listitem><simpara><literal>UPDATE</literal></simpara></listitem>
<listitem><simpara><literal>DELETE</literal></simpara></listitem>
<listitem><simpara><literal>INSERT</literal></simpara></listitem>
<listitem><simpara><literal>CREATE</literal></simpara></listitem>
<listitem><simpara><literal>DROP</literal></simpara></listitem>
<listitem><simpara><literal>ALTER</literal></simpara></listitem>
<listitem><simpara><literal>BEGIN</literal></simpara></listitem>
<listitem><simpara><literal>DECLARE</literal></simpara></listitem>
<listitem><simpara><literal>CALL</literal> (since PHP 5.2.1 and OCI8
1.2.3)</simpara></listitem>
<listitem><simpara><literal>UNKNOWN</literal></simpara></listitem>
</orderedlist>
Returns the type of <parameter>statement</parameter> as one of the
following strings.
<table>
<title>Statement type</title>
<tgroup cols="2">
<thead>
<row>
<entry>Return String</entry>
<entry>Notes</entry>
</row>
</thead>
<tbody>
<row>
<entry><literal>ALTER</literal></entry>
<entry>&nbsp;</entry>
</row>
<row>
<entry><literal>BEGIN</literal></entry>
<entry>&nbsp;</entry>
</row>
<row>
<entry><literal>CALL</literal></entry>
<entry>Introduced in PHP 5.2.1 (PECL OCI8 1.2.3)</entry>
</row>
<row>
<entry><literal>CREATE</literal></entry>
<entry>&nbsp;</entry>
</row>
<row>
<entry><literal>DECLARE</literal></entry>
<entry>&nbsp;</entry>
</row>
<row>
<entry><literal>DELETE</literal></entry>
<entry>&nbsp;</entry>
</row>
<row>
<entry><literal>DROP</literal></entry>
<entry>&nbsp;</entry>
</row>
<row>
<entry><literal>INSERT</literal></entry>
<entry>&nbsp;</entry>
</row>
<row>
<entry><literal>SELECT</literal></entry>
<entry>&nbsp;</entry>
</row>
<row>
<entry><literal>UPDATE</literal></entry>
<entry>&nbsp;</entry>
</row>
<row>
<entry><literal>UNKNOWN</literal></entry>
<entry>&nbsp;</entry>
</row>
</tbody>
</tgroup>
</table>
</para>
<para>
Returns &false; on error.
</para>
</refsect1>
@ -64,15 +110,20 @@
<programlisting role="php">
<![CDATA[
<?php
$conn = oci_connect("scott", "tiger");
$sql = "delete from emp where deptno = 10";
$stmt = oci_parse($conn, $sql);
if (oci_statement_type($stmt) == "DELETE") {
die("You are not allowed to delete from this table<br />");
}
$conn = oci_connect('hr', 'welcome', 'localhost/XE');
$stid = oci_parse($conn, 'DELETE FROM departments WHERE department_id = 130;');
if (oci_statement_type($stid) == "DELETE") {
trigger_error('You are not allowed to delete from this table', E_USER_ERROR);
}
else {
oci_execute($stid); // delete the row
}
oci_free_statement($stid);
oci_close($conn);
oci_close($conn);
?>
]]>
</programlisting>
@ -84,10 +135,9 @@
&reftitle.notes;
<note>
<para>
In PHP versions before 5.0.0 you must use <function>ocistatementtype</function> instead.
This name still can be used, it was left as alias of
<function>oci_statement_type</function> for downwards compatability.
This, however, is deprecated and not recommended.
In PHP versions before 5.0.0 you must
use <function>ocistatementtype</function> instead.
&oci.name.compat.note;
</para>
</note>
</refsect1>