📄 pdostatement.fetch.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head> <title>Fetches the next row from a result set</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> </head> <body><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="pdostatement.execute.html">PDOStatement->execute</a></div> <div class="next" style="text-align: right; float: right;"><a href="pdostatement.fetchall.html">PDOStatement->fetchAll</a></div> <div class="up"><a href="class.pdostatement.html">PDOStatement</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div><hr /><div id="pdostatement.fetch" class="refentry"> <div class="refnamediv"> <h1 class="refname">PDOStatement->fetch</h1> <p class="verinfo">(No version information available, might be only in CVS)</p><p class="refpurpose"><span class="refname">PDOStatement->fetch</span> — <span class="dc-title"> Fetches the next row from a result set </span></p> </div> <div class="refsect1 description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <span class="methodname"><b><b>PDOStatement::fetch</b></b></span> ([ <span class="methodparam"><span class="type">int</span> <tt class="parameter">$fetch_style</tt></span> [, <span class="methodparam"><span class="type">int</span> <tt class="parameter">$cursor_orientation</tt></span> [, <span class="methodparam"><span class="type">int</span> <tt class="parameter">$cursor_offset</tt></span> ]]] )</div> <p class="para rdfs-comment"> Fetches a row from a result set associated with a PDOStatement object. The <i><tt class="parameter">fetch_style</tt></i> parameter determines how PDO returns the row. </p> </div> <div class="refsect1 parameters"> <h3 class="title">Parameters</h3> <p class="para"> <dl> <dt> <span class="term"><i><tt class="parameter">fetch_style</tt></i></span> <dd> <p class="para"> Controls how the next row will be returned to the caller. This value must be one of the <i>PDO::FETCH_*</i> constants, defaulting to <i>PDO::FETCH_BOTH</i>. <ul class="itemizedlist"> <li class="listitem"><p class="para"> <i>PDO::FETCH_ASSOC</i>: returns an array indexed by column name as returned in your result set </p></li> <li class="listitem"><p class="para"> <i>PDO::FETCH_BOTH</i> (default): returns an array indexed by both column name and 0-indexed column number as returned in your result set </p></li> <li class="listitem"><p class="para"> <i>PDO::FETCH_BOUND</i>: returns <b><tt>TRUE</tt></b> and assigns the values of the columns in your result set to the PHP variables to which they were bound with the <a href="pdostatement.bindcolumn.html" class="function">PDOStatement::bindColumn()</a> method </p></li> <li class="listitem"><p class="para"> <i>PDO::FETCH_CLASS</i>: returns a new instance of the requested class, mapping the columns of the result set to named properties in the class. If <i><tt class="parameter">fetch_style</tt></i> includes PDO::FETCH_CLASSTYPE (e.g. <i>PDO::FETCH_CLASS | PDO::FETCH_CLASSTYPE</i>) then the name of the class is determined from a value of the first column. </p></li> <li class="listitem"><p class="para"> <i>PDO::FETCH_INTO</i>: updates an existing instance of the requested class, mapping the columns of the result set to named properties in the class </p></li> <li class="listitem"><p class="para"> <i>PDO::FETCH_LAZY</i>: combines <i>PDO::FETCH_BOTH</i> and <i>PDO::FETCH_OBJ</i>, creating the object variable names as they are accessed </p></li> <li class="listitem"><p class="para"> <i>PDO::FETCH_NUM</i>: returns an array indexed by column number as returned in your result set, starting at column 0 </p></li> <li class="listitem"><p class="para"> <i>PDO::FETCH_OBJ</i>: returns an anonymous object with property names that correspond to the column names returned in your result set </p></li> </ul> </p> </dd> </dt> <dt> <span class="term"><i><tt class="parameter">cursor_orientation</tt></i></span> <dd> <p class="para"> For a PDOStatement object representing a scrollable cursor, this value determines which row will be returned to the caller. This value must be one of the <i>PDO::FETCH_ORI_*</i> constants, defaulting to <i>PDO::FETCH_ORI_NEXT</i>. To request a scrollable cursor for your PDOStatement object, you must set the <i>PDO::ATTR_CURSOR</i> attribute to <i>PDO::CURSOR_SCROLL</i> when you prepare the SQL statement with <a href="pdo.prepare.html" class="function">PDO::prepare()</a>. </p> </dd> </dt> <dt> <span class="term"><i><tt class="parameter">offset</tt></i>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -