Sophie

Sophie

distrib > Mageia > 4 > x86_64 > by-pkgid > f800694edefe91adea2624f711a41a2d > files > 2386

php-manual-en-5.5.7-1.mga4.noarch.rpm

<!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><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.cubrid-get.html">cubrid_get</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.cubrid-is-instance.html">cubrid_is_instance</a></div>
 <div class="up"><a href="ref.cubrid.html">CUBRID Functions</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="function.cubrid-insert-id" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">cubrid_insert_id</h1>
  <p class="verinfo">(PECL CUBRID &gt;= 8.3.0)</p><p class="refpurpose"><span class="refname">cubrid_insert_id</span> &mdash; <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">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="type">string</span> <span class="methodname"><strong>cubrid_insert_id</strong></span>
    ([ <span class="methodparam"><span class="type">resource</span> <code class="parameter">$conn_identifier</code></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">Parameters</h3>
 <p class="para">
  <dl>

   <dt>

    <span class="term"><em><code class="parameter">conn_identifier</code></em></span>
    <dd>
<p class="para">
      The connection identifier previously obtained by a call to
       <span class="function"><a href="function.cubrid-connect.html" class="function">cubrid_connect()</a></span>.
    </p></dd>

   </dt>

  </dl>

 </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.cubrid-insert-id-returnvalues">
  <h3 class="title">Return Values</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">Changelog</h3>
  <p class="para">
   <table class="doctable informaltable">
    
     <thead>
      <tr>
       <th>Version</th>
       <th>Description</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">Examples</h3>
  <div class="example" id="example-1027">
   <p><strong>Example #1  <span class="function"><strong>cubrid_insert_id()</strong></span> example</strong></p>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$conn&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">cubrid_connect</span><span style="color: #007700">(</span><span style="color: #DD0000">"localhost"</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">33000</span><span style="color: #007700">,&nbsp;</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">,&nbsp;</span><span style="color: #DD0000">"DROP&nbsp;TABLE&nbsp;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">,&nbsp;</span><span style="color: #DD0000">"CREATE&nbsp;TABLE&nbsp;cubrid_test&nbsp;(d&nbsp;int&nbsp;AUTO_INCREMENT(1,&nbsp;2),&nbsp;t&nbsp;varchar)"</span><span style="color: #007700">);<br /><br />for&nbsp;(</span><span style="color: #0000BB">$i&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">0</span><span style="color: #007700">;&nbsp;</span><span style="color: #0000BB">$i&nbsp;</span><span style="color: #007700">&lt;&nbsp;</span><span style="color: #0000BB">10</span><span style="color: #007700">;&nbsp;</span><span style="color: #0000BB">$i</span><span style="color: #007700">++)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">cubrid_execute</span><span style="color: #007700">(</span><span style="color: #0000BB">$conn</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"INSERT&nbsp;INTO&nbsp;cubrid_test(t)&nbsp;VALUES('cubrid_test')"</span><span style="color: #007700">);<br />}<br /><br /></span><span style="color: #0000BB">$id&nbsp;</span><span style="color: #007700">=&nbsp;</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">?&gt;</span>
</span>
</code></div>
   </div>

    <div class="example-contents"><p>The above example will output:</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
string(2) &quot;19&quot;
</pre></div>
    </div>
  </div>
 </div>


</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.cubrid-get.html">cubrid_get</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.cubrid-is-instance.html">cubrid_is_instance</a></div>
 <div class="up"><a href="ref.cubrid.html">CUBRID Functions</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>