<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.uodbc.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'zh',
  ),
  'this' => 
  array (
    0 => 'function.odbc-execute.php',
    1 => 'odbc_execute',
    2 => 'Execute a prepared statement',
  ),
  'up' => 
  array (
    0 => 'ref.uodbc.php',
    1 => 'ODBC 函数',
  ),
  'prev' => 
  array (
    0 => 'function.odbc-exec.php',
    1 => 'odbc_exec',
  ),
  'next' => 
  array (
    0 => 'function.odbc-fetch-array.php',
    1 => 'odbc_fetch_array',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/uodbc/functions/odbc-execute.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.odbc-execute" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">odbc_execute</h1>
  <p class="verinfo">(PHP 4, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">odbc_execute</span> &mdash; <span class="dc-title">Execute a prepared statement</span></p>

 </div>
 
 <div class="refsect1 description" id="refsect1-function.odbc-execute-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>odbc_execute</strong></span>(<span class="methodparam"><span class="type">Odbc\Result</span> <code class="parameter">$statement</code></span>, <span class="methodparam"><span class="type"><a href="language.types.array.php" class="type array">array</a></span> <code class="parameter">$params</code><span class="initializer"> = []</span></span>): <span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span></div>

  <p class="para rdfs-comment">
   Executes a statement prepared with <span class="function"><a href="function.odbc-prepare.php" class="function">odbc_prepare()</a></span>.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.odbc-execute-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">statement</code></dt>
     <dd>
      <p class="para">
       ODBC 结果对象 from <span class="function"><a href="function.odbc-prepare.php" class="function">odbc_prepare()</a></span>.
      </p>
     </dd>
    
    
     <dt><code class="parameter">params</code></dt>
     <dd>
      <p class="para">
       Parameters in <code class="parameter">params</code> will be
       substituted for placeholders in the prepared statement in order.
       Elements of this array will be converted to strings by calling this
       function.
      </p>
      <p class="para">
       Any parameters in <code class="parameter">params</code> which
       start and end with single quotes will be taken as the name of a
       file to read and send to the database server as the data for the
       appropriate placeholder.
      </p>
      <span class="simpara">
       If you wish to store a string which actually begins and ends with
       single quotes, you must add a space or other non-single-quote character
       to the beginning or end of the parameter, which will prevent the
       parameter from being taken as a file name. If this is not an option,
       then you must use another mechanism to store the string, such as
       executing the query directly with <span class="function"><a href="function.odbc-exec.php" class="function">odbc_exec()</a></span>).
      </span>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.odbc-execute-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   成功时返回 <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong>， 或者在失败时返回 <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong>。
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.odbc-execute-changelog">
  <h3 class="title">更新日志</h3>
  <table class="doctable informaltable">
   
    <thead>
     <tr>
      <th>版本</th>
      <th>说明</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
 <td>8.4.0</td>
 <td>
  此函数现在返回 <span class="classname"><strong class="classname">Odbc\Result</strong></span>
  实例；之前返回 <span class="type"><a href="language.types.resource.php" class="type resource">resource</a></span>。
 </td>
</tr>

     <tr>
      <td>8.0.0</td>
      <td>
       The unused <code class="parameter">flags</code> parameter was removed.
      </td>
     </tr>

    </tbody>
   
  </table>

 </div>


 <div class="refsect1 examples" id="refsect1-function.odbc-execute-examples">
  <h3 class="title">示例</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>示例 #1 <span class="function"><strong>odbc_execute()</strong></span> and <span class="function"><a href="function.odbc-prepare.php" class="function">odbc_prepare()</a></span> example</strong></p>
    <div class="example-contents"><p>
     In the following code, <var class="varname">$success</var> will only be
     <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong> if all three parameters to myproc are IN parameters:
    </p></div>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$a </span><span style="color: #007700">= </span><span style="color: #0000BB">1</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$b </span><span style="color: #007700">= </span><span style="color: #0000BB">2</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$c </span><span style="color: #007700">= </span><span style="color: #0000BB">3</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$stmt    </span><span style="color: #007700">= </span><span style="color: #0000BB">odbc_prepare</span><span style="color: #007700">(</span><span style="color: #0000BB">$conn</span><span style="color: #007700">, </span><span style="color: #DD0000">'CALL myproc(?,?,?)'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$success </span><span style="color: #007700">= </span><span style="color: #0000BB">odbc_execute</span><span style="color: #007700">(</span><span style="color: #0000BB">$stmt</span><span style="color: #007700">, array(</span><span style="color: #0000BB">$a</span><span style="color: #007700">, </span><span style="color: #0000BB">$b</span><span style="color: #007700">, </span><span style="color: #0000BB">$c</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

   </div>
  </p>
  <p class="para">
   If you need to call a stored procedure using INOUT or OUT parameters,
   the recommended workaround is to use a native extension for your database
   (for example, <a href="ref.oci8.php" class="link">oci8</a> for Oracle).
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.odbc-execute-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="function"><a href="function.odbc-prepare.php" class="function" rel="rdfs-seeAlso">odbc_prepare()</a> - Prepares a statement for execution</span></li>
   </ul>
  </p>
 </div>


</div><?php manual_footer($setup); ?>