php8.5
Home/ Manual/ oci8 / functions/ oci_statement_type

oci_statement_type

PHP function Edit on GitHub ✎

(PHP 5, PHP 7, PHP 8, PECL OCI8 >= 1.1.0)

Returns the type of a statement

Description

oci_statement_type(resource $statement): string|false

Returns a keyword identifying the type of the OCI8 statement.

Parameters

statement

A valid OCI8 statement identifier from oci_parse().

Return Values

Returns the type of statement as one of the following strings.

Return StringNotes
ALTER
BEGIN
CALL
CREATE
DECLARE
DELETE
DROP
INSERT
SELECT
UPDATE
UNKNOWN

Returns false on error.

Examples

oci_statement_type() example

php
<?php

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

$stid = oci_parse($conn, 'DELETE FROM departments WHERE department_id = 130;');
if (oci_statement_type($stid) == "DELETE") {
    trigger_error('You are not allowed to delete from this table', E_USER_ERROR);
}
else {
    oci_execute($stid);  // delete the row
}

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

?>

Source: reference/oci8/functions/oci-statement-type.xml · from the official PHP manual (php/doc-en)