<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/class.mysqli-stmt.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'zh',
  ),
  'this' => 
  array (
    0 => 'mysqli-stmt.attr-set.php',
    1 => 'mysqli_stmt::attr_set',
    2 => 'Used to modify the behavior of a prepared statement',
  ),
  'up' => 
  array (
    0 => 'class.mysqli-stmt.php',
    1 => 'mysqli_stmt',
  ),
  'prev' => 
  array (
    0 => 'mysqli-stmt.attr-get.php',
    1 => 'mysqli_stmt::attr_get',
  ),
  'next' => 
  array (
    0 => 'mysqli-stmt.bind-param.php',
    1 => 'mysqli_stmt::bind_param',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/mysqli/mysqli_stmt/attr-set.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="mysqli-stmt.attr-set" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">mysqli_stmt::attr_set</h1>
  <h1 class="refname">mysqli_stmt_attr_set</h1>
  <p class="verinfo">(PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">mysqli_stmt::attr_set</span> -- <span class="refname">mysqli_stmt_attr_set</span> &mdash; <span class="dc-title">Used to modify the behavior of a prepared statement</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-mysqli-stmt.attr-set-description">
  <h3 class="title">说明</h3>
  <p class="para">面向对象风格</p>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><strong>mysqli_stmt::attr_set</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$attribute</code></span>, <span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$value</code></span>): <span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span></div>

  <p class="para rdfs-comment">过程化风格</p>
  <div class="methodsynopsis dc-description"><span class="methodname"><strong>mysqli_stmt_attr_set</strong></span>(<span class="methodparam"><span class="type"><a href="class.mysqli-stmt.php" class="type mysqli_stmt">mysqli_stmt</a></span> <code class="parameter">$statement</code></span>, <span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$attribute</code></span>, <span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$value</code></span>): <span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span></div>

  <p class="para rdfs-comment">
   Used to modify the behavior of a prepared statement. This function may be
   called multiple times to set several attributes.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-mysqli-stmt.attr-set-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl><dt>
<code class="parameter">statement</code></dt><dd><p class="para">仅以过程化样式:由
<span class="function"><a href="mysqli.stmt-init.php" class="function">mysqli_stmt_init()</a></span> 返回的 <span class="classname"><a href="class.mysqli-stmt.php" class="classname">mysqli_stmt</a></span> 对象。</p></dd>
     <dt><code class="parameter">attribute</code></dt>
     <dd>
      <p class="para">
       The attribute that you want to set. It can have one of the following values:
       <table id="mysqli-stmt.attr-set.parameters" class="doctable table">
        <caption><strong>Attribute values</strong></caption>
        
         <thead>
          <tr>
           <th>Character</th>
           <th>Description</th>
          </tr>

         </thead>

         <tbody class="tbody">
          <tr>
           <td>MYSQLI_STMT_ATTR_UPDATE_MAX_LENGTH</td>
           <td>
            Setting to <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong> causes <span class="function"><a href="mysqli-stmt.store-result.php" class="function">mysqli_stmt_store_result()</a></span> to
            update the metadata <code class="literal">MYSQL_FIELD-&gt;max_length</code> value.
           </td>
          </tr>

          <tr>
           <td>MYSQLI_STMT_ATTR_CURSOR_TYPE</td>
           <td>
            Type of cursor to open for statement when <span class="function"><a href="mysqli-stmt.execute.php" class="function">mysqli_stmt_execute()</a></span>
            is invoked. <code class="parameter">value</code> can be <strong><code><a href="mysqli.constants.php#constant.mysqli-cursor-type-no-cursor">MYSQLI_CURSOR_TYPE_NO_CURSOR</a></code></strong>
            (the default) or <strong><code><a href="mysqli.constants.php#constant.mysqli-cursor-type-read-only">MYSQLI_CURSOR_TYPE_READ_ONLY</a></code></strong>.
           </td>
          </tr>

          <tr>
           <td>MYSQLI_STMT_ATTR_PREFETCH_ROWS</td>
           <td>
            Number of rows to fetch from server at a time when using a cursor.
            <code class="parameter">value</code> can be in the range from 1 to the maximum
            value of unsigned long. The default is 1.
            Removed as of PHP 8.4.0.
           </td>
          </tr>

         </tbody>
        
       </table>

      </p>
      <p class="para">
       If you use the <strong><code><a href="mysqli.constants.php#constant.mysqli-stmt-attr-cursor-type">MYSQLI_STMT_ATTR_CURSOR_TYPE</a></code></strong> option with
       <strong><code><a href="mysqli.constants.php#constant.mysqli-cursor-type-read-only">MYSQLI_CURSOR_TYPE_READ_ONLY</a></code></strong>, a cursor is opened for the
       statement when you invoke <span class="function"><a href="mysqli-stmt.execute.php" class="function">mysqli_stmt_execute()</a></span>. If there
       is already an open cursor from a previous <span class="function"><a href="mysqli-stmt.execute.php" class="function">mysqli_stmt_execute()</a></span> call,
       it closes the cursor before opening a new one. <span class="function"><a href="mysqli-stmt.reset.php" class="function">mysqli_stmt_reset()</a></span>
       also closes any open cursor before preparing the statement for re-execution.
       <span class="function"><a href="mysqli-stmt.free-result.php" class="function">mysqli_stmt_free_result()</a></span> closes any open cursor.
      </p>
      <p class="para">
       If you open a cursor for a prepared statement, <span class="function"><a href="mysqli-stmt.store-result.php" class="function">mysqli_stmt_store_result()</a></span>
       is unnecessary.
      </p>
     </dd>
    
    
     <dt><code class="parameter">value</code></dt>
     <dd>
      <p class="para">The value to assign to the attribute.</p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-mysqli-stmt.attr-set-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 errors" id="refsect1-mysqli-stmt.attr-set-errors">
  <h3 class="title">错误/异常</h3>
  <p class="para">
If mysqli error reporting is enabled (<strong><code><a href="mysqli.constants.php#constant.mysqli-report-error">MYSQLI_REPORT_ERROR</a></code></strong>) and the requested operation fails,
a warning is generated. If, in addition, the mode is set to <strong><code><a href="mysqli.constants.php#constant.mysqli-report-strict">MYSQLI_REPORT_STRICT</a></code></strong>,
a <span class="classname"><a href="class.mysqli-sql-exception.php" class="classname">mysqli_sql_exception</a></span> is thrown instead.</p>
 </div>


 <div class="refsect1 seealso" id="refsect1-mysqli-stmt.attr-set-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li><a href="http://dev.mysql.com/doc/en/mysql-stmt-attr-set.html" class="link external">&raquo;&nbsp;Connector/MySQL mysql_stmt_attr_set()</a></li>
   </ul>
  </p>
 </div>


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