<?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 => 'ja',
  ),
  'this' => 
  array (
    0 => 'mysqli-stmt.attr-set.php',
    1 => 'mysqli_stmt::attr_set',
    2 => 'プリペアドステートメントの振る舞いを変更する',
  ),
  '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' => 'ja',
    '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">プリペアドステートメントの振る舞いを変更する</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">
   プリペアドステートメントの振る舞いを変更します。
   複数の属性を設定するには、この関数を複数回コールします。
  </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">stmt</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">
       設定したい属性。次のいずれかの値となります。
       <table id="mysqli-stmt.attr-set.parameters" class="doctable table">
        <caption><strong>属性の値</strong></caption>
        
         <thead>
          <tr>
           <th>文字</th>
           <th>説明</th>
          </tr>

         </thead>

         <tbody class="tbody">
          <tr>
           <td>MYSQLI_STMT_ATTR_UPDATE_MAX_LENGTH</td>
           <td>
            <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong> に設定すると、<span class="function"><a href="mysqli-stmt.store-result.php" class="function">mysqli_stmt_store_result()</a></span> は
            メタデータ <code class="literal">MYSQL_FIELD-&gt;max_length</code> の値を上書きします。
           </td>
          </tr>

          <tr>
           <td>MYSQLI_STMT_ATTR_CURSOR_TYPE</td>
           <td>
            <span class="function"><a href="mysqli-stmt.execute.php" class="function">mysqli_stmt_execute()</a></span>
            が起動された際にステートメントをオープンするためのカーソル型。
            <code class="parameter">value</code> は、<strong><code><a href="mysqli.constants.php#constant.mysqli-cursor-type-no-cursor">MYSQLI_CURSOR_TYPE_NO_CURSOR</a></code></strong>
            (デフォルト) あるいは <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>
            カーソルの使用時にサーバーからいちどに取得する行数。
            <code class="parameter">value</code> に指定できる値の範囲は
            1 から unsigned long の最大値までで、デフォルトは 1 です。
            PHP 8.4.0 で削除されました。
           </td>
          </tr>

         </tbody>
        
       </table>

      </p>
      <p class="para">
       <strong><code><a href="mysqli.constants.php#constant.mysqli-stmt-attr-cursor-type">MYSQLI_STMT_ATTR_CURSOR_TYPE</a></code></strong> オプションで
       <strong><code><a href="mysqli.constants.php#constant.mysqli-cursor-type-read-only">MYSQLI_CURSOR_TYPE_READ_ONLY</a></code></strong> を使用すると、
       <span class="function"><a href="mysqli-stmt.execute.php" class="function">mysqli_stmt_execute()</a></span>
       を起動した際にそのステートメント用のカーソルをオープンします。
       以前に <span class="function"><a href="mysqli-stmt.execute.php" class="function">mysqli_stmt_execute()</a></span>
       をコールした際にオープンしたカーソルが残っている場合は、
       それを閉じてから新しいカーソルをオープンします。また
       <span class="function"><a href="mysqli-stmt.reset.php" class="function">mysqli_stmt_reset()</a></span>
       も、オープンしているカーソルをすべて閉じてからステートメント再実行の準備をします。
       <span class="function"><a href="mysqli-stmt.free-result.php" class="function">mysqli_stmt_free_result()</a></span>
       は、オープンしているカーソルをすべて閉じます。
      </p>
      <p class="para">
       プリペアドステートメント用のカーソルをオープンするのなら
       <span class="function"><a href="mysqli-stmt.store-result.php" class="function">mysqli_stmt_store_result()</a></span> は不要です。
      </p>
     </dd>
    
    
     <dt><code class="parameter">value</code></dt>
     <dd>
      <p class="para">属性に割り当てるモード。</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">
mysqli のエラー報告 (<strong><code><a href="mysqli.constants.php#constant.mysqli-report-error">MYSQLI_REPORT_ERROR</a></code></strong>) が有効になっており、かつ要求された操作が失敗した場合は、警告が発生します。さらに、エラー報告のモードが <strong><code><a href="mysqli.constants.php#constant.mysqli-report-strict">MYSQLI_REPORT_STRICT</a></code></strong> に設定されていた場合は、<span class="classname"><a href="class.mysqli-sql-exception.php" class="classname">mysqli_sql_exception</a></span> が代わりにスローされます。</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); ?>