PageRenderTime 45ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/php/function.oci-fetch.html

https://bitbucket.org/thncr/manuals
HTML | 131 lines | 109 code | 22 blank | 0 comment | 0 complexity | 36b040d609ba29f430d0eac3e26bae10 MD5 | raw file
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <html>
  3. <head>
  4. <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  5. <title>Fetches the next row into result-buffer</title>
  6. </head>
  7. <body><div class="manualnavbar" style="text-align: center;">
  8. <div class="prev" style="text-align: left; float: left;"><a href="function.oci-fetch-row.html">oci_fetch_row</a></div>
  9. <div class="next" style="text-align: right; float: right;"><a href="function.oci-field-is-null.html">oci_field_is_null</a></div>
  10. <div class="up"><a href="ref.oci8.html">OCI8 函数</a></div>
  11. <div class="home"><a href="index.html">PHP Manual</a></div>
  12. </div><hr /><div id="function.oci-fetch" class="refentry">
  13. <div class="refnamediv">
  14. <h1 class="refname">oci_fetch</h1>
  15. <p class="verinfo">(PHP 5, PECL OCI8 &gt;= 1.1.0)</p><p class="refpurpose"><span class="refname">oci_fetch</span> &mdash; <span class="dc-title">Fetches the next row into result-buffer</span></p>
  16. </div>
  17. <div class="refsect1 description" id="refsect1-function.oci-fetch-description">
  18. <h3 class="title">说明</h3>
  19. <div class="methodsynopsis dc-description">
  20. <span class="type">bool</span> <span class="methodname"><strong>oci_fetch</strong></span>
  21. ( <span class="methodparam"><span class="type">resource</span> <code class="parameter">$statement</code></span>
  22. )</div>
  23. <p class="para rdfs-comment">
  24. <span class="function"><strong>oci_fetch()</strong></span> 获取下一行对于 SELECT 语句到内部结果缓冲区
  25. </p>
  26. <blockquote class="note"><p><strong class="note">Note</strong>:
  27. <p class="para">
  28. PHP 5.0.0 之前的版本必须使用 <span class="function"><a href="function.ocifetch.html" class="function">ocifetch()</a></span>
  29. 替代本函数该函数名仍然可用为向下兼容作为
  30. <span class="function"><strong>oci_fetch()</strong></span> 的别名不过其已被废弃不推荐使用
  31. </p>
  32. </p></blockquote>
  33. </div>
  34. <div class="refsect1 parameters" id="refsect1-function.oci-fetch-parameters">
  35. <h3 class="title">参数</h3>
  36. <p class="para">
  37. <dl>
  38. <dt>
  39. <span class="term"><em><code class="parameter">statement</code></em></span>
  40. <dd>
  41. <p class="para">有效的 OCI8 报表标识符
  42. <span class="function"><a href="function.oci-parse.html" class="function">oci_parse()</a></span> 创建 <span class="function"><a href="function.oci-execute.html" class="function">oci_execute()</a></span>
  43. <em>REF CURSOR</em> statement 标识执行</p>
  44. </dd>
  45. </dt>
  46. </dl>
  47. </p>
  48. </div>
  49. <div class="refsect1 returnvalues" id="refsect1-function.oci-fetch-returnvalues">
  50. <h3 class="title">返回值</h3>
  51. <p class="para">
  52. Returns <strong><code>TRUE</code></strong> on success or <strong><code>FALSE</code></strong> if there are no more rows in the
  53. <em><code class="parameter">statement</code></em>.
  54. </p>
  55. </div>
  56. <div class="refsect1 examples" id="refsect1-function.oci-fetch-examples">
  57. <h3 class="title">范例</h3>
  58. <p class="para">
  59. <div class="example" id="example-2010">
  60. <p><strong>Example #1 <span class="function"><strong>oci_fetch()</strong></span> with defined variables</strong></p>
  61. <div class="example-contents">
  62. <div class="phpcode"><code><span style="color: #000000">
  63. <span style="color: #0000BB">&lt;?php<br /><br />$conn&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">oci_connect</span><span style="color: #007700">(</span><span style="color: #DD0000">'hr'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'welcome'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'localhost/XE'</span><span style="color: #007700">);<br />if&nbsp;(!</span><span style="color: #0000BB">$conn</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$e&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">oci_error</span><span style="color: #007700">();<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">trigger_error</span><span style="color: #007700">(</span><span style="color: #0000BB">htmlentities</span><span style="color: #007700">(</span><span style="color: #0000BB">$e</span><span style="color: #007700">[</span><span style="color: #DD0000">'message'</span><span style="color: #007700">],&nbsp;</span><span style="color: #0000BB">ENT_QUOTES</span><span style="color: #007700">),&nbsp;</span><span style="color: #0000BB">E_USER_ERROR</span><span style="color: #007700">);<br />}<br /><br /></span><span style="color: #0000BB">$sql&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">'SELECT&nbsp;location_id,&nbsp;city&nbsp;FROM&nbsp;locations&nbsp;WHERE&nbsp;location_id&nbsp;&lt;&nbsp;1200'</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$stid&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">oci_parse</span><span style="color: #007700">(</span><span style="color: #0000BB">$conn</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$sql</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">//&nbsp;The&nbsp;defines&nbsp;MUST&nbsp;be&nbsp;done&nbsp;before&nbsp;executing<br /></span><span style="color: #0000BB">oci_define_by_name</span><span style="color: #007700">(</span><span style="color: #0000BB">$stid</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'LOCATION_ID'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$locid</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">oci_define_by_name</span><span style="color: #007700">(</span><span style="color: #0000BB">$stid</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'CITY'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$city</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">oci_execute</span><span style="color: #007700">(</span><span style="color: #0000BB">$stid</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">//&nbsp;Each&nbsp;fetch&nbsp;populates&nbsp;the&nbsp;previously&nbsp;defined&nbsp;variables&nbsp;with&nbsp;the&nbsp;next&nbsp;row's&nbsp;data<br /></span><span style="color: #007700">while&nbsp;(</span><span style="color: #0000BB">oci_fetch</span><span style="color: #007700">(</span><span style="color: #0000BB">$stid</span><span style="color: #007700">))&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"Location&nbsp;id&nbsp;</span><span style="color: #0000BB">$locid</span><span style="color: #DD0000">&nbsp;is&nbsp;</span><span style="color: #0000BB">$city</span><span style="color: #DD0000">&lt;br&gt;\n"</span><span style="color: #007700">;<br />}<br /><br /></span><span style="color: #FF8000">//&nbsp;Displays:<br />//&nbsp;&nbsp;&nbsp;Location&nbsp;id&nbsp;1000&nbsp;is&nbsp;Roma<br />//&nbsp;&nbsp;&nbsp;Location&nbsp;id&nbsp;1100&nbsp;is&nbsp;Venice<br /><br /></span><span style="color: #0000BB">oci_free_statement</span><span style="color: #007700">(</span><span style="color: #0000BB">$stid</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">oci_close</span><span style="color: #007700">(</span><span style="color: #0000BB">$conn</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">?&gt;</span>
  64. </span>
  65. </code></div>
  66. </div>
  67. </div>
  68. </p>
  69. <p class="para">
  70. <div class="example" id="example-2011">
  71. <p><strong>Example #2 <span class="function"><strong>oci_fetch()</strong></span> with <span class="function"><a href="function.oci-result.html" class="function">oci_result()</a></span></strong></p>
  72. <div class="example-contents">
  73. <div class="phpcode"><code><span style="color: #000000">
  74. <span style="color: #0000BB">&lt;?php<br /><br />$conn&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">oci_connect</span><span style="color: #007700">(</span><span style="color: #DD0000">'hr'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'welcome'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'localhost/XE'</span><span style="color: #007700">);<br />if&nbsp;(!</span><span style="color: #0000BB">$conn</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$e&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">oci_error</span><span style="color: #007700">();<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">trigger_error</span><span style="color: #007700">(</span><span style="color: #0000BB">htmlentities</span><span style="color: #007700">(</span><span style="color: #0000BB">$e</span><span style="color: #007700">[</span><span style="color: #DD0000">'message'</span><span style="color: #007700">],&nbsp;</span><span style="color: #0000BB">ENT_QUOTES</span><span style="color: #007700">),&nbsp;</span><span style="color: #0000BB">E_USER_ERROR</span><span style="color: #007700">);<br />}<br /><br /></span><span style="color: #0000BB">$sql&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">'SELECT&nbsp;location_id,&nbsp;city&nbsp;FROM&nbsp;locations&nbsp;WHERE&nbsp;location_id&nbsp;&lt;&nbsp;1200'</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$stid&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">oci_parse</span><span style="color: #007700">(</span><span style="color: #0000BB">$conn</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$sql</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">oci_execute</span><span style="color: #007700">(</span><span style="color: #0000BB">$stid</span><span style="color: #007700">);<br /><br />while&nbsp;(</span><span style="color: #0000BB">oci_fetch</span><span style="color: #007700">(</span><span style="color: #0000BB">$stid</span><span style="color: #007700">))&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #0000BB">oci_result</span><span style="color: #007700">(</span><span style="color: #0000BB">$stid</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'LOCATION_ID'</span><span style="color: #007700">)&nbsp;.&nbsp;</span><span style="color: #DD0000">"&nbsp;is&nbsp;"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #0000BB">oci_result</span><span style="color: #007700">(</span><span style="color: #0000BB">$stid</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'CITY'</span><span style="color: #007700">)&nbsp;.&nbsp;</span><span style="color: #DD0000">"&lt;br&gt;\n"</span><span style="color: #007700">;<br />}<br /><br /></span><span style="color: #FF8000">//&nbsp;Displays:<br />//&nbsp;&nbsp;&nbsp;1000&nbsp;is&nbsp;Roma<br />//&nbsp;&nbsp;&nbsp;1100&nbsp;is&nbsp;Venice<br /><br /></span><span style="color: #0000BB">oci_free_statement</span><span style="color: #007700">(</span><span style="color: #0000BB">$stid</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">oci_close</span><span style="color: #007700">(</span><span style="color: #0000BB">$conn</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">?&gt;</span>
  75. </span>
  76. </code></div>
  77. </div>
  78. </div>
  79. </p>
  80. </div>
  81. <div class="refsect1 notes" id="refsect1-function.oci-fetch-notes">
  82. <h3 class="title">注释</h3>
  83. <blockquote class="note"><p><strong class="note">Note</strong>:
  84. <p class="para">
  85. In PHP versions before 5.0.0 use <span class="function"><a href="function.ocifetch.html" class="function">ocifetch()</a></span>
  86. instead. 在当前版本中旧的函数名还可以被使用但已经被废弃并不建议使用
  87. </p>
  88. </p></blockquote>
  89. </div>
  90. <div class="refsect1 seealso" id="refsect1-function.oci-fetch-seealso">
  91. <h3 class="title">参见</h3>
  92. <p class="para">
  93. <ul class="simplelist">
  94. <li class="member"> <span class="function"><a href="function.oci-define-by-name.html" class="function" rel="rdfs-seeAlso">oci_define_by_name()</a> - SELECT 中使用 PHP 变量作为定义的步骤</span></li>
  95. <li class="member"> <span class="function"><a href="function.oci-fetch-all.html" class="function" rel="rdfs-seeAlso">oci_fetch_all()</a> - 获取结果数据的所有行到一个数组</span></li>
  96. <li class="member"> <span class="function"><a href="function.oci-fetch-array.html" class="function" rel="rdfs-seeAlso">oci_fetch_array()</a> - Returns the next row from a query as an associative or numeric array</span></li>
  97. <li class="member"> <span class="function"><a href="function.oci-fetch-assoc.html" class="function" rel="rdfs-seeAlso">oci_fetch_assoc()</a> - Returns the next row from a query as an associative array</span></li>
  98. <li class="member"> <span class="function"><a href="function.oci-fetch-object.html" class="function" rel="rdfs-seeAlso">oci_fetch_object()</a> - Returns the next row from a query as an object</span></li>
  99. <li class="member"> <span class="function"><a href="function.oci-fetch-row.html" class="function" rel="rdfs-seeAlso">oci_fetch_row()</a> - Returns the next row from a query as a numeric array</span></li>
  100. <li class="member"> <span class="function"><a href="function.oci-result.html" class="function" rel="rdfs-seeAlso">oci_result()</a> - 返回所取得行中字段的值</span></li>
  101. </ul>
  102. </p>
  103. </div>
  104. </div><hr /><div class="manualnavbar" style="text-align: center;">
  105. <div class="prev" style="text-align: left; float: left;"><a href="function.oci-fetch-row.html">oci_fetch_row</a></div>
  106. <div class="next" style="text-align: right; float: right;"><a href="function.oci-field-is-null.html">oci_field_is_null</a></div>
  107. <div class="up"><a href="ref.oci8.html">OCI8 函数</a></div>
  108. <div class="home"><a href="index.html">PHP Manual</a></div>
  109. </div></body></html>