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

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

oci_execute

(PHP 5, PECL OCI8 >= 1.1.0)

oci_execute — 執行一條語句

說明

bool oci_execute ( resource $stmt [, int $mode ] )

oci_execute() 執行一條之前被解析過的語句(見 oci_parse())。可選參數 mode 允許定義執行模式(默認是 OCI_COMMIT_ON_SUCCESS)。如果不需要將語句自動提交,則需要把 mode 設為 OCI_DEFAULT

OCI_DEFAULT 模式時,將建立一個事務。事務會在關閉連接或腳本結束時(看哪個先)自動回卷。需要明確調用 oci_commit() 來提交事務,或者 oci_rollback() 中止事務。

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

Note:

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

參數

statement

A valid OCI statement identifier.

mode

An optional second parameter can be one of the following constants: Execution Modes Constant Description OCI_COMMIT_ON_SUCCESS Automatically commit all outstanding changes for this connection when the statement has succeeded. This is the default. OCI_DEFAULT Obsolete as of PHP 5.3.2 (PECL OCI8 1.4) but still available for backward compatibility. Use the equivalent OCI_NO_AUTO_COMMIT in new code. OCI_DESCRIBE_ONLY Make query meta data available to functions like oci_field_name() but do not create a result set. Any subsequent fetch call such as oci_fetch_array() will fail. OCI_NO_AUTO_COMMIT Do not automatically commit changes. Prior to PHP 5.3.2 (PECL OCI8 1.4) use OCI_DEFAULT which is an alias for OCI_NO_AUTO_COMMIT.

Using OCI_NO_AUTO_COMMIT mode starts a transaction. Transactions are automatically rolled back when the connection is closed, or when the script ends. Explicitly call oci_commit() to commit a transaction, or oci_rollback() to abort it.

When inserting or updating data, using transactions is recommended for relational data consistency and for performance reasons.

If OCI_NO_AUTO_COMMIT mode is used for any statement including queries, and oci_commit() or oci_rollback() is not subsequently called, then OCI8 will perform a rollback at the end of the script even if no data was changed. To avoid an unnecessary rollback, many scripts do not use OCI_NO_AUTO_COMMIT mode for queries or PL/SQL. Be careful to ensure the appropriate transactional consistency for the application when using oci_execute() with different modes in the same script.

返回值

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

范例

Example #1 oci_execute() for queries

<?php

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

$stid = oci_parse($conn, 'SELECT * FROM employees');
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";

?>

Example #2 oci_execute() without specifying a mode example

<?php

// Before running, create the table:
//   CREATE TABLE MYTABLE (col1 NUMBER);

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

$stid = oci_parse($conn, 'INSERT INTO mytab (col1) VALUES (123)');

oci_execute($stid); // The row is committed and immediately visible to other users

?>

Example #3 oci_execute() with OCI_NO_AUTO_COMMIT example

<?php

// Before running, create the table:
//   CREATE TABLE MYTABLE (col1 NUMBER);

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

$stid = oci_parse($conn, 'INSERT INTO mytab (col1) VALUES (:bv)');
oci_bind_by_name($stid, ':bv', $i, 10);
for ($i = 1; $i <= 5; ++$i) {
    oci_execute($stid, OCI_NO_AUTO_COMMIT);  // use OCI_DEFAULT for PHP <= 5.3.1
}
oci_commit($conn);  // commits all new values: 1, 2, 3, 4, 5

?>

Example #4 oci_execute() with different commit modes example

<?php

// Before running, create the table:
//   CREATE TABLE MYTABLE (col1 NUMBER);

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

$stid = oci_parse($conn, 'INSERT INTO mytab (col1) VALUES (123)');
oci_execute($stid, OCI_NO_AUTO_COMMIT);  // data not committed

$stid = oci_parse($conn, 'INSERT INTO mytab (col1) VALUES (456)');
oci_execute($stid);  // commits both 123 and 456 values

?>

Example #5 oci_execute() with OCI_DESCRIBE_ONLY example

<?php

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

$stid = oci_parse($conn, 'SELECT * FROM locations');
oci_execute($s, OCI_DESCRIBE_ONLY);
for ($i = 1; $i <= oci_num_fields($stid); ++$i) {
    echo oci_field_name($stid, $i) . "<br>n";
}

?>

注釋

Note:

Transactions are automatically rolled back when connections are closed, or when the script ends, whichever is soonest. Explicitly call oci_commit() to commit a transaction.

Any call to oci_execute() that uses OCI_COMMIT_ON_SUCCESS mode explicitly or by default will commit any previous uncommitted transaction.

Any Oracle DDL statement such as CREATE or DROP will automatically commit any uncommitted transaction.

Note:

Because the oci_execute() function generally sends the statement to the database, oci_execute() can identify some statement syntax errors that the lightweight, local oci_parse() function does not.

Note:

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

參見

oci_parse() - 配置 Oracle 語句預備執行


主站蜘蛛池模板: kaori全部av作品大全| 廊桥遗梦演员表| 电影九龙城寨| 好茶叶排名前十名| xiee| 蜘蛛女侠| 爱的重生| 韩国电影陈诗雅主演| 丧尸童子军| 向退休生活游戏正版赚钱入口| 日本女人xxx| 中华英雄何润东| 上香香灰打卷图解| 夏日福星 电影| 体温36.5度正常吗| 破天荒| 柏欣彤12点以后跳的广场舞| 阿尔罕布拉宫的回忆吉他谱| 欧美日本视频在线| 深圳古镇| 电视剧狂飙演员名单| 一级特黄新婚之夜| bbbbbbbbb免费毛片视频| 放下一个人最狠的网名| 女同版痴汉电车| 爱欲1990未删减版播放| 色,戒在线观看| 悦来换电| 成品直播大全免费观看| 土壤动植物的乐园教学反思| 李保田演的全部作品| 少儿不宜视频| 内蒙古电视台节目表| 以下关于宏病毒说法正确的是| the girl next door| 小恩雅骑马舞蹈视频| 机动战士高达seed destiny| 谁的青春不迷茫 电影| smc压力表| 湖南金鹰卡通节目表| 庞敏|

!!!站長長期在線接!!!

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

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

站長微信:lxwl520520

站長QQ:1737366103