mirror of
https://github.com/fofolee/uTools-Manuals.git
synced 2025-06-28 20:35:50 +08:00
128 lines
6.3 KiB
HTML
128 lines
6.3 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
<html>
|
|
<head>
|
|
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
|
<title>Return the ID generated for the last updated AUTO_INCREMENT column</title>
|
|
</head>
|
|
<body class="docs"><div id="layout">
|
|
<div id="layout-content"><div id="function.cubrid-insert-id" class="refentry">
|
|
<div class="refnamediv">
|
|
<h1 class="refname">cubrid_insert_id</h1>
|
|
<p class="verinfo">(PECL CUBRID >= 8.3.0)</p><p class="refpurpose"><span class="refname">cubrid_insert_id</span> — <span class="dc-title">Return the ID generated for the last updated <strong><code>AUTO_INCREMENT</code></strong> column</span></p>
|
|
|
|
</div>
|
|
|
|
<div class="refsect1 description" id="refsect1-function.cubrid-insert-id-description">
|
|
<h3 class="title">说明</h3>
|
|
<div class="methodsynopsis dc-description">
|
|
<span class="methodname"><strong>cubrid_insert_id</strong></span>
|
|
([ <span class="methodparam"><span class="type">resource</span> <code class="parameter">$conn_identifier</code></span>
|
|
] ) : <span class="type">string</span></div>
|
|
|
|
<p class="para rdfs-comment">
|
|
The <span class="function"><strong>cubrid_insert_id()</strong></span> function retrieves the ID
|
|
generated for the AUTO_INCREMENT column which is updated by the previous
|
|
INSERT query. It returns 0 if the previous query does not generate new
|
|
rows, or FALSE on failure.
|
|
</p>
|
|
|
|
<blockquote class="note"><p><strong class="note">Note</strong>:
|
|
<p class="para">
|
|
CUBRID supports AUTO_INCREMENT for more than one columns in a table. In
|
|
most cases, there will be a single AUTO_INCREMENT column in a table. If
|
|
there are multiple AUTO_INCREMENT columns, this function should not be
|
|
used even if it will return a value.
|
|
</p>
|
|
</p></blockquote>
|
|
</div>
|
|
|
|
|
|
<div class="refsect1 parameters" id="refsect1-function.cubrid-insert-id-parameters">
|
|
<h3 class="title">参数</h3>
|
|
<p class="para">
|
|
<dl>
|
|
|
|
|
|
<dt>
|
|
<code class="parameter">conn_identifier</code></dt>
|
|
|
|
<dd>
|
|
<p class="para">
|
|
The connection identifier previously obtained by a call to
|
|
<span class="function"><a href="cubrid_connect.html" class="function">cubrid_connect()</a></span>.
|
|
</p></dd>
|
|
|
|
|
|
</dl>
|
|
|
|
</p>
|
|
</div>
|
|
|
|
|
|
<div class="refsect1 returnvalues" id="refsect1-function.cubrid-insert-id-returnvalues">
|
|
<h3 class="title">返回值</h3>
|
|
<p class="para">
|
|
A string representing the ID generated for an AUTO_INCREMENT column by the
|
|
previous query, on success.
|
|
</p>
|
|
<p class="para">
|
|
0, if the previous query does not generate new rows.
|
|
</p>
|
|
<p class="para">
|
|
<strong><code>FALSE</code></strong> on failure.
|
|
</p>
|
|
</div>
|
|
|
|
|
|
<div class="refsect1 changelog" id="refsect1-function.cubrid-insert-id-changelog">
|
|
<h3 class="title">更新日志</h3>
|
|
<p class="para">
|
|
<table class="doctable informaltable">
|
|
|
|
<thead>
|
|
<tr>
|
|
<th>版本</th>
|
|
<th>说明</th>
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody class="tbody">
|
|
<tr>
|
|
<td>8.4.0</td>
|
|
<td>
|
|
Change the return value from an array to string; Remove the first
|
|
parameter class_name.
|
|
</td>
|
|
</tr>
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
</p>
|
|
</div>
|
|
|
|
|
|
<div class="refsect1 examples" id="refsect1-function.cubrid-insert-id-examples">
|
|
<h3 class="title">范例</h3>
|
|
<div class="example" id="example-1117">
|
|
<p><strong>Example #1 <span class="function"><strong>cubrid_insert_id()</strong></span> example</strong></p>
|
|
<div class="example-contents">
|
|
<div class="phpcode"><pre><span style="color: #000000">
|
|
<span style="color: #0000BB"><?php<br />$conn </span><span style="color: #007700">= </span><span style="color: #0000BB">cubrid_connect</span><span style="color: #007700">(</span><span style="color: #DD0000">"localhost"</span><span style="color: #007700">, </span><span style="color: #0000BB">33000</span><span style="color: #007700">, </span><span style="color: #DD0000">"demodb"</span><span style="color: #007700">);<br /><br />@</span><span style="color: #0000BB">cubrid_execute</span><span style="color: #007700">(</span><span style="color: #0000BB">$conn</span><span style="color: #007700">, </span><span style="color: #DD0000">"DROP TABLE cubrid_test"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">cubrid_execute</span><span style="color: #007700">(</span><span style="color: #0000BB">$conn</span><span style="color: #007700">, </span><span style="color: #DD0000">"CREATE TABLE cubrid_test (d int AUTO_INCREMENT(1, 2), t varchar)"</span><span style="color: #007700">);<br /><br />for (</span><span style="color: #0000BB">$i </span><span style="color: #007700">= </span><span style="color: #0000BB">0</span><span style="color: #007700">; </span><span style="color: #0000BB">$i </span><span style="color: #007700">< </span><span style="color: #0000BB">10</span><span style="color: #007700">; </span><span style="color: #0000BB">$i</span><span style="color: #007700">++) {<br /> </span><span style="color: #0000BB">cubrid_execute</span><span style="color: #007700">(</span><span style="color: #0000BB">$conn</span><span style="color: #007700">, </span><span style="color: #DD0000">"INSERT INTO cubrid_test(t) VALUES('cubrid_test')"</span><span style="color: #007700">);<br />}<br /><br /></span><span style="color: #0000BB">$id </span><span style="color: #007700">= </span><span style="color: #0000BB">cubrid_insert_id</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$id</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">cubrid_disconnect</span><span style="color: #007700">(</span><span style="color: #0000BB">$conn</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?></span>
|
|
</span>
|
|
</pre></div>
|
|
</div>
|
|
|
|
<div class="example-contents"><p>以上例程会输出:</p></div>
|
|
<div class="example-contents screen">
|
|
<div class="cdata"><pre>
|
|
string(2) "19"
|
|
</pre></div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
</div></div></div></body></html> |