File: cubrid-execute.xml

package info (click to toggle)
php-doc 20250827~git.abe740d%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 71,968 kB
  • sloc: xml: 985,760; php: 25,504; javascript: 671; sh: 177; makefile: 37
file content (204 lines) | stat: -rw-r--r-- 7,146 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->

<refentry xml:id="function.cubrid-execute" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
 <refnamediv>
  <refname>cubrid_execute</refname>
  <refpurpose>Execute a prepared SQL statement</refpurpose>
 </refnamediv>

 <refsect1 role="description">
  &reftitle.description;
  <methodsynopsis>
   <type>resource</type><methodname>cubrid_execute</methodname>
   <methodparam><type>resource</type><parameter>conn_identifier</parameter></methodparam>  
   <methodparam><type>string</type><parameter>sql</parameter></methodparam>  
   <methodparam choice="opt"><type>int</type><parameter>option</parameter><initializer>0</initializer></methodparam>  
  </methodsynopsis>
  <methodsynopsis>
   <type>bool</type><methodname>cubrid_execute</methodname>
   <methodparam><type>resource</type><parameter>request_identifier</parameter></methodparam>  
   <methodparam choice="opt"><type>int</type><parameter>option</parameter><initializer>0</initializer></methodparam>  
  </methodsynopsis>
    <para>
      The <function>cubrid_execute</function> function is used to execute the
      given SQL statement. It executes the query by using
      <parameter>conn_identifier</parameter> and SQL, and then returns the
      request identifier created. It is used for simple execution of query,
      where the parameter binding is not needed. In addition, the
      <function>cubrid_execute</function> function is used to execute the
      prepared statement by means of <function>cubrid_prepare</function> and
      <function>cubrid_bind</function>. At this time, you need to specify
      arguments of <parameter>request_identifier</parameter> and
      <parameter>option</parameter>.
    </para>
    <para>
     The <parameter>option</parameter> is used to determine whether to get OID
     after query execution and whether to execute the query in synchronous or
     asynchronous mode. <constant>CUBRID_INCLUDE_OID</constant> and <constant>CUBRID_ASYNC</constant> (or
     <constant>CUBRID_EXEC_QUERY_ALL</constant> if you want to execute multiple SQL statements) can
     be specified by using a bitwise OR operator. If not specified, neither of
     them isselected. If the flag <constant>CUBRID_EXEC_QUERY_ALL</constant> is set, a synchronous
     mode (sync_mode) is used to retrieve query results, and in such cases the
     following rules are applied: 
    </para>
    <para>
     <simplelist>
      <member>The return value is the result of the first query.</member>
      <member>
       If an error occurs in any query, the execution is processed as a
       failure.
      </member>
      <member>
       In a query composed of q1 q2 q3, if an error
       occurs in q2 after q1 succeeds the execution, the result of q1 remains
       valid. That is, the previous successful query executions are not rolled
       back when an error occurs.
      </member>
      <member>
       If a query is executed successfully, the result of the second query can
       be obtained using <function>cubrid_next_result</function>.
      </member>
     </simplelist>
    </para>
    <para>
     If the first argument is <parameter>request_identifier</parameter> to
     execute the <function>cubrid_prepare</function> function, you can specify
     an option, <constant>CUBRID_ASYNC</constant> only.
    </para>
 </refsect1>

  <refsect1 role="parameters">
 &reftitle.parameters;
 <para>
      <variablelist>
        <varlistentry>
      <term><parameter>conn_identifier</parameter></term>
      <listitem><para>Connection identifier.</para></listitem>
       </varlistentry>
       <varlistentry>
      <term><parameter>sql</parameter></term>
      <listitem><para>SQL to be executed.</para></listitem>
       </varlistentry>
       <varlistentry>
      <term><parameter>option</parameter></term>
        <listitem><para>Query execution option <constant>CUBRID_INCLUDE_OID</constant>, <constant>CUBRID_ASYNC</constant>, <constant>CUBRID_EXEC_QUERY_ALL</constant>.</para></listitem>
       </varlistentry>
        <varlistentry>
      <term><parameter>request_identifier</parameter></term>
      <listitem><para><function>cubrid_prepare</function> identifier.</para></listitem>
       </varlistentry>
      </variablelist>
  </para>
 </refsect1>

 <refsect1 role="returnvalues">
  &reftitle.returnvalues;
  <para>
    Request identifier, when process is successful and first param is
    conn_identifier; &true;, when process is successful and first argument is
    request_identifier,&return.falseforfailure;.
  </para>
 </refsect1>

 <refsect1 role="changelog">
  &reftitle.changelog;
  <para>
   <informaltable>
    <tgroup cols="2">
     <thead>
      <row>
       <entry>&Version;</entry>
       <entry>&Description;</entry>
      </row>
     </thead>
     <tbody>
      <row>
       <entry>8.4.0</entry>
       <entry>
        Add new option <constant>CUBRID_EXEC_QUERY_ALL</constant>.
       </entry>
      </row>
     </tbody>
    </tgroup>
   </informaltable>
  </para>
 </refsect1>

 <refsect1 role="examples">
  &reftitle.examples;
  <example>
   <title><function>cubrid_execute</function> example</title>
   <programlisting role="php">
<![CDATA[
<?php
$conn = cubrid_connect("localhost", 33000, "demodb");

$result = cubrid_execute($conn, "SELECT code FROM event WHERE name='100m Butterfly' and gender='M'", CUBRID_ASYNC);
$row = cubrid_fetch_array($result, CUBRID_ASSOC);
$event_code = $row["code"];

cubrid_close_request($result);

$history_req = cubrid_prepare($conn, "SELECT * FROM history WHERE event_code=?");
cubrid_bind($history_req, 1, $event_code, "number");
cubrid_execute($history_req);

printf("%-20s %-9s %-10s %-5s\n", "athlete", "host_year", "score", "unit");
while ($row = cubrid_fetch_array($history_req, CUBRID_ASSOC)) {
    printf("%-20s %-9s %-10s %-5s\n", 
        $row["athlete"], $row["host_year"], $row["score"], $row["unit"]);
}

cubrid_close_request($history_req);

cubrid_disconnect($conn);
?>
]]>
   </programlisting>
    &example.outputs;
    <screen>
<![CDATA[
athlete              host_year score      unit 
Phelps Michael       2004      51.25      time 
]]>
   </screen>
  </example>
 </refsect1>

   <refsect1 role="seealso">
  &reftitle.seealso;
  <para>
   <simplelist>
   <member><function>cubrid_prepare</function></member>
   <member><function>cubrid_bind</function></member>
   <member><function>cubrid_next_result</function></member>
   <member><function>cubrid_close_request</function></member>
   <member><function>cubrid_commit</function></member>
   <member><function>cubrid_rollback</function></member>
   </simplelist>
  </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
-->