成人精品一区二区三区中文字幕-成人精品一区二区三区-成人精品一级毛片-成人精品亚洲-日本在线视频一区二区-日本在线视频免费

導航首頁 ? 技術教程 ? PHP:oci_set_prefetch()的用法_Oracle函數
全站頭部文字 我要出現在這里
PHP:oci_set_prefetch()的用法_Oracle函數 749 2023-12-12   

oci_set_prefetch

(PHP 5, PECL OCI8 >= 1.1.0)

oci_set_prefetch — 設置預提取行數

說明

bool oci_set_prefetch ( resource $statement [, int $rows ] )

在成功調用 oci_execute() 之后設定預提取的行數。rows 的默認值為 1。

Note:

在 PHP 5.0.0 之前的版本必須使用 ocisetprefetch() 替代本函數。該函數名仍然可用,為向下兼容作為 oci_set_prefetch() 的別名。不過其已被廢棄,不推薦使用。

成功時返回 TRUE, 或者在失敗時返回 FALSE

參見 oci8_.default_prefetch INI 選項。

參數

statement

有效的 OCI8 報表標識符 由 oci_parse() 創建,被 oci_execute() 或 REF CURSOR statement 標識執行。

rows

The number of rows to be prefetched, >= 0

返回值

成功時返回 TRUE, 或者在失敗時返回 FALSE。

更新日志

版本 說明 PHP 5.3.2 (PECL OCI8 1.4) Before this release, rows must be >= 1. PHP 5.3 (PECL OCI8 1.3.4) Before this release, prefetching was limited to the lesser of rows rows and 1024 * rows bytes. The byte size restriction has now been removed.

范例

Example #1 Changing the default prefetch value for a query

<?php

$conn = oci_connect('hr', 'welcome', 'localhost/XE');

$stid = oci_parse($conn, 'SELECT * FROM myverybigtable');
oci_set_prefetch($stid, 300);  // Set before calling oci_execute()
oci_execute($stid);

echo "<table border='1'>n";
while ($row = oci_fetch_array($stid, OCI_ASSOC+OCI_RETURN_NULLS)) {
    echo "<tr>n";
    foreach ($row as $item) {
        echo "    <td>".($item !== null ? htmlentities($item, ENT_QUOTES) : "&nbsp;")."</td>n";
    }
    echo "</tr>n";
}
echo "</table>n";

oci_free_statement($stid);
oci_close($conn);

?>

Example #2 Changing the default prefetch for a REF CURSOR fetch

<?php
/*
  Create the PL/SQL stored procedure as:

  CREATE OR REPLACE PROCEDURE myproc(p1 OUT SYS_REFCURSOR) AS
  BEGIN
    OPEN p1 FOR SELECT * FROM all_objects WHERE ROWNUM < 5000;
  END;
*/

$conn = oci_connect('hr', 'welcome', 'localhost/XE');

$stid = oci_parse($conn, 'BEGIN myproc(:rc); END;');
$refcur = oci_new_cursor($conn);
oci_bind_by_name($stid, ':rc', $refcur, -1, OCI_B_CURSOR);
oci_execute($stid);

// Change the prefetch before executing the cursor.
// REF CURSOR prefetching works when PHP is linked with Oracle 11gR2 Client libraries
oci_set_prefetch($refcur, 200);
oci_execute($refcur);

echo "<table border='1'>n";
while ($row = oci_fetch_array($refcur, OCI_ASSOC+OCI_RETURN_NULLS)) {
    echo "<tr>n";
    foreach ($row as $item) {
        echo "    <td>".($item !== null ? htmlentities($item, ENT_QUOTES) : "&nbsp;")."</td>n";
    }
    echo "</tr>n";
}
echo "</table>n";

oci_free_statement($refcur);
oci_free_statement($stid);
oci_close($conn);

?>

If PHP OCI8 fetches from a REF CURSOR and then passes the REF CURSOR back to a second PL/SQL procedure for further processing, then set the REF CURSOR prefetch count to 0 to avoid rows being "lost" from the result set. The prefetch value is the number of extra rows fetched in each OCI8 internal request to the database, so setting it to 0 means only fetch one row at a time.

Example #3 Setting the prefetch value when passing a REF CURSOR back to Oracle

<?php

$conn = oci_connect('hr', 'welcome', 'localhost/orcl');

// get the REF CURSOR
$stid = oci_parse($conn, 'BEGIN myproc(:rc_out); END;');
$refcur = oci_new_cursor($conn);
oci_bind_by_name($stid, ':rc_out', $refcur, -1, OCI_B_CURSOR);
oci_execute($stid);

// Display two rows, but don't prefetch any extra rows otherwise
// those extra rows would not be passed back to myproc_use_rc().
// A prefetch value of 0 is allowed in PHP 5.3.2 and PECL OCI8 1.4
oci_set_prefetch($refcur, 0);
oci_execute($refcur);
$row = oci_fetch_array($refcur);
var_dump($row);
$row = oci_fetch_array($refcur);
var_dump($row);

// pass the REF CURSOR to myproc_use_rc() to do more data processing
// with the result set
$stid = oci_parse($conn, 'begin myproc_use_rc(:rc_in); end;'); 
oci_bind_by_name($stid, ':rc_in', $refcur, -1, OCI_B_CURSOR);
oci_execute($stid);

?>

注釋

Note:

In PHP versions before 5.0.0 use ocisetprefetch() instead. 在當前版本中,舊的函數名還可以被使用,但已經被廢棄并不建議使用。

參見

oci8.default_prefetch ini option


主站蜘蛛池模板: 同妻俱乐部| 无内秘书| 湖南卫视节目表| 詹姆斯怀特| 误判电影什么时候上映| paigeturnah大白臀| 抖音手机网页版| 梁洪硕| 流浪地球免费观看| 红旗车驾驶员个人主要事迹材料 | 回到黑暗 电影| 教学评一体化课题研究| 扒开下面让我添| 13位的电话号码是什么电话 | 无内秘书| 香谱七十二法图大全| 情难自禁电影| 阳光阿坝| 江湖之社团风暴| ab变频器中文说明书| 小镇追凶电影免费观看| 音乐会电视剧免费观看完整版| 李俊宇| 电影名《瞎子传奇》| 贪玩的小水滴300字完整版| 朱莉娅·安经典在线观看| 黄视频免费在线观看| 宋小莹| 花非花电视剧演员表| 花煞| 抖音国际版| 少林问道演员表| 庆余年2演员表全部员表| 红灯区未删减版| 火舞俪人 电影| 红星闪闪歌词完整版打印| 美女网站视频免费| 巴黎最后的探戈| 开创盛世电视剧全集免费观看| 黄网站在线免费| 刘浩存《一秒钟》舞蹈|

!??!站長長期在線接?。。?/p>

網站、小程序:定制開發/二次開發/仿制開發等

各種疑難雜癥解決/定制接口/定制采集等

站長微信:lxwl520520

站長QQ:1737366103