函数名称:oci_statement_type
函数描述:获取OCI语句的类型,返回OCI语句的类型常量。
适用版本:PHP 5,PHP 7
语法:oci_statement_type ( resource $statement ) : string|false
参数:
返回值:
示例:
// 创建一个OCI连接
$conn = oci_connect('username', 'password', 'localhost/ORCL');
// 准备一个OCI语句
$sql = "SELECT * FROM employees";
$statement = oci_parse($conn, $sql);
// 执行OCI语句
oci_execute($statement);
// 获取OCI语句类型
$statementType = oci_statement_type($statement);
// 根据OCI语句类型进行不同的操作
if ($statementType == OCI_SELECT_STATEMENT) {
// 处理SELECT语句的结果集
while ($row = oci_fetch_assoc($statement)) {
// 处理每一行数据
// ...
}
} elseif ($statementType == OCI_DESCRIBE_STATEMENT) {
// 处理DESCRIBE语句的结果
// ...
} elseif ($statementType == OCI_COMMIT_ON_SUCCESS) {
// 处理COMMIT_ON_SUCCESS语句
// ...
}
// 关闭OCI语句和连接
oci_free_statement($statement);
oci_close($conn);
注意事项: