<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/class.pdostatement.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'zh',
  ),
  'this' => 
  array (
    0 => 'pdostatement.setattribute.php',
    1 => 'PDOStatement::setAttribute',
    2 => '设置一个语句属性',
  ),
  'up' => 
  array (
    0 => 'class.pdostatement.php',
    1 => 'PDOStatement',
  ),
  'prev' => 
  array (
    0 => 'pdostatement.rowcount.php',
    1 => 'PDOStatement::rowCount',
  ),
  'next' => 
  array (
    0 => 'pdostatement.setfetchmode.php',
    1 => 'PDOStatement::setFetchMode',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'zh',
    'path' => 'reference/pdo/pdostatement/setattribute.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="pdostatement.setattribute" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">PDOStatement::setAttribute</h1>
  <p class="verinfo">(PHP 5 &gt;= 5.1.0, PHP 7, PHP 8, PECL pdo &gt;= 0.2.0)</p><p class="refpurpose"><span class="refname">PDOStatement::setAttribute</span> &mdash; <span class="dc-title">
   设置一个语句属性
  </span></p>

 </div>
 <div class="refsect1 description" id="refsect1-pdostatement.setattribute-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><strong>PDOStatement::setAttribute</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.mixed.php" class="type mixed">mixed</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">
   给语句设置一个属性。当前，没有通用的属性可以设置，只有驱动特定的属性：
   <ul class="itemizedlist">
    <li class="listitem"><p class="para"><code class="literal">PDO::ATTR_CURSOR_NAME</code>
    （Firebird 和 ODBC 特性）：
     为 <code class="literal">UPDATE ... WHERE CURRENT OF</code> 设置游标名称。
    </p></li>
   </ul>
   请注意，驱动特定的属性<em>不得</em>与其他驱动程序一起使用。
  </p>

 </div>


 <div class="refsect1 parameters" id="refsect1-pdostatement.setattribute-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">attribute</code></dt>
     <dd>
      <p class="para">
       要修改的属性。
      </p>
     </dd>
    
    
     <dt><code class="parameter">value</code></dt>
     <dd>
      <p class="para">
       设置 <code class="parameter">attribute</code> 的值，属性的不同导致需要的类型也会不同。
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-pdostatement.setattribute-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 seealso" id="refsect1-pdostatement.setattribute-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="methodname"><a href="pdo.getattribute.php" class="methodname" rel="rdfs-seeAlso">PDO::getAttribute()</a> - 取回一个数据库连接的属性</span></li>
    <li><span class="methodname"><a href="pdo.setattribute.php" class="methodname" rel="rdfs-seeAlso">PDO::setAttribute()</a> - 设置属性</span></li>
    <li><span class="methodname"><a href="pdostatement.getattribute.php" class="methodname" rel="rdfs-seeAlso">PDOStatement::getAttribute()</a> - 检索语句属性</span></li>
   </ul>
  </p>
 </div>


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