| 1 |
<?php |
| 2 |
|
| 3 |
namespace Safe; |
| 4 |
|
| 5 |
use Safe\Exceptions\Oci8Exception; |
| 6 |
|
| 7 |
/** |
| 8 |
* Binds the PHP array var_array to the Oracle |
| 9 |
* placeholder name, which points to an Oracle PL/SQL |
| 10 |
* array. Whether it will be used for input or output will be determined at |
| 11 |
* run-time. |
| 12 |
* |
| 13 |
* @param resource $statement A valid OCI statement identifier. |
| 14 |
* @param string $name The Oracle placeholder. |
| 15 |
* @param array $var_array An array. |
| 16 |
* @param int $max_table_length Sets the maximum length both for incoming and result arrays. |
| 17 |
* @param int $max_item_length Sets maximum length for array items. If not specified or equals to -1, |
| 18 |
* oci_bind_array_by_name will find the longest |
| 19 |
* element in the incoming array and will use it as the maximum length. |
| 20 |
* @param int $type Should be used to set the type of PL/SQL array items. See list of |
| 21 |
* available types below: |
| 22 |
* |
| 23 |
* |
| 24 |
* |
| 25 |
* |
| 26 |
* SQLT_NUM - for arrays of NUMBER. |
| 27 |
* |
| 28 |
* |
| 29 |
* |
| 30 |
* |
| 31 |
* SQLT_INT - for arrays of INTEGER (Note: INTEGER |
| 32 |
* it is actually a synonym for NUMBER(38), but |
| 33 |
* SQLT_NUM type won't work in this case even |
| 34 |
* though they are synonyms). |
| 35 |
* |
| 36 |
* |
| 37 |
* |
| 38 |
* |
| 39 |
* SQLT_FLT - for arrays of FLOAT. |
| 40 |
* |
| 41 |
* |
| 42 |
* |
| 43 |
* |
| 44 |
* SQLT_AFC - for arrays of CHAR. |
| 45 |
* |
| 46 |
* |
| 47 |
* |
| 48 |
* |
| 49 |
* SQLT_CHR - for arrays of VARCHAR2. |
| 50 |
* |
| 51 |
* |
| 52 |
* |
| 53 |
* |
| 54 |
* SQLT_VCS - for arrays of VARCHAR. |
| 55 |
* |
| 56 |
* |
| 57 |
* |
| 58 |
* |
| 59 |
* SQLT_AVC - for arrays of CHARZ. |
| 60 |
* |
| 61 |
* |
| 62 |
* |
| 63 |
* |
| 64 |
* SQLT_STR - for arrays of STRING. |
| 65 |
* |
| 66 |
* |
| 67 |
* |
| 68 |
* |
| 69 |
* SQLT_LVC - for arrays of LONG VARCHAR. |
| 70 |
* |
| 71 |
* |
| 72 |
* |
| 73 |
* |
| 74 |
* SQLT_ODT - for arrays of DATE. |
| 75 |
* |
| 76 |
* |
| 77 |
* |
| 78 |
* |
| 79 |
* SQLT_NUM - for arrays of NUMBER. |
| 80 |
* |
| 81 |
* SQLT_INT - for arrays of INTEGER (Note: INTEGER |
| 82 |
* it is actually a synonym for NUMBER(38), but |
| 83 |
* SQLT_NUM type won't work in this case even |
| 84 |
* though they are synonyms). |
| 85 |
* |
| 86 |
* SQLT_FLT - for arrays of FLOAT. |
| 87 |
* |
| 88 |
* SQLT_AFC - for arrays of CHAR. |
| 89 |
* |
| 90 |
* SQLT_CHR - for arrays of VARCHAR2. |
| 91 |
* |
| 92 |
* SQLT_VCS - for arrays of VARCHAR. |
| 93 |
* |
| 94 |
* SQLT_AVC - for arrays of CHARZ. |
| 95 |
* |
| 96 |
* SQLT_STR - for arrays of STRING. |
| 97 |
* |
| 98 |
* SQLT_LVC - for arrays of LONG VARCHAR. |
| 99 |
* |
| 100 |
* SQLT_ODT - for arrays of DATE. |
| 101 |
* @throws Oci8Exception |
| 102 |
* |
| 103 |
*/ |
| 104 |
function oci_bind_array_by_name($statement, string $name, array &$var_array, int $max_table_length, int $max_item_length = -1, int $type = SQLT_AFC): void |
| 105 |
{ |
| 106 |
error_clear_last(); |
| 107 |
$result = \oci_bind_array_by_name($statement, $name, $var_array, $max_table_length, $max_item_length, $type); |
| 108 |
if ($result === false) { |
| 109 |
throw Oci8Exception::createFromPhpError(); |
| 110 |
} |
| 111 |
} |
| 112 |
|
| 113 |
|
| 114 |
/** |
| 115 |
* Binds a PHP variable variable to the Oracle |
| 116 |
* bind variable placeholder bv_name. Binding |
| 117 |
* is important for Oracle database performance and also as a way to |
| 118 |
* avoid SQL Injection security issues. |
| 119 |
* |
| 120 |
* Binding allows the database to reuse the statement context and |
| 121 |
* caches from previous executions of the statement, even if another |
| 122 |
* user or process originally executed it. Binding reduces SQL |
| 123 |
* Injection concerns because the data associated with a bind |
| 124 |
* variable is never treated as part of the SQL statement. It does |
| 125 |
* not need quoting or escaping. |
| 126 |
* |
| 127 |
* PHP variables that have been bound can be changed and the |
| 128 |
* statement re-executed without needing to re-parse the statement or |
| 129 |
* re-bind. |
| 130 |
* |
| 131 |
* In Oracle, bind variables are commonly divided |
| 132 |
* into IN binds for values that are passed into |
| 133 |
* the database, and OUT binds for values that are |
| 134 |
* returned to PHP. A bind variable may be |
| 135 |
* both IN and OUT. Whether a |
| 136 |
* bind variable will be used for input or output is determined at |
| 137 |
* run-time. |
| 138 |
* |
| 139 |
* You must specify maxlength when using |
| 140 |
* an OUT bind so that PHP allocates enough memory |
| 141 |
* to hold the returned value. |
| 142 |
* |
| 143 |
* For IN binds it is recommended to set |
| 144 |
* the maxlength length if the statement is |
| 145 |
* re-executed multiple times with different values for the PHP |
| 146 |
* variable. Otherwise Oracle may truncate data to the length of the |
| 147 |
* initial PHP variable value. If you don't know what the maximum |
| 148 |
* length will be, then re-call oci_bind_by_name |
| 149 |
* with the current data size prior to |
| 150 |
* each oci_execute call. Binding an |
| 151 |
* unnecessarily large length will have an impact on process memory |
| 152 |
* in the database. |
| 153 |
* |
| 154 |
* A bind call tells Oracle which memory address to read data from. |
| 155 |
* For IN binds that address needs to contain |
| 156 |
* valid data when oci_execute is called. This |
| 157 |
* means that the variable bound must remain in scope until |
| 158 |
* execution. If it doesn't, unexpected results or errors such as |
| 159 |
* "ORA-01460: unimplemented or unreasonable conversion requested" |
| 160 |
* may occur. For OUT binds one symptom is no |
| 161 |
* value being set in the PHP variable. |
| 162 |
* |
| 163 |
* For a statement that is repeatedly executed, binding values that |
| 164 |
* never change may reduce the ability of the Oracle optimizer to |
| 165 |
* choose the best statement execution plan. Long running statements |
| 166 |
* that are rarely re-executed may not benefit from binding. However |
| 167 |
* in both cases, binding might be safer than joining strings into a |
| 168 |
* SQL statement, as this can be a security risk if unfiltered user |
| 169 |
* text is concatenated. |
| 170 |
* |
| 171 |
* @param resource $statement A valid OCI8 statement identifer. |
| 172 |
* @param string $bv_name The colon-prefixed bind variable placeholder used in the |
| 173 |
* statement. The colon is optional |
| 174 |
* in bv_name. Oracle does not use question |
| 175 |
* marks for placeholders. |
| 176 |
* @param mixed $variable The PHP variable to be associated with bv_name |
| 177 |
* @param int $maxlength Sets the maximum length for the data. If you set it to -1, this |
| 178 |
* function will use the current length |
| 179 |
* of variable to set the maximum |
| 180 |
* length. In this case the variable must |
| 181 |
* exist and contain data |
| 182 |
* when oci_bind_by_name is called. |
| 183 |
* @param int $type The datatype that Oracle will treat the data as. The |
| 184 |
* default type used |
| 185 |
* is SQLT_CHR. Oracle will convert the data |
| 186 |
* between this type and the database column (or PL/SQL variable |
| 187 |
* type), when possible. |
| 188 |
* |
| 189 |
* If you need to bind an abstract datatype (LOB/ROWID/BFILE) you |
| 190 |
* need to allocate it first using the |
| 191 |
* oci_new_descriptor function. The |
| 192 |
* length is not used for abstract datatypes |
| 193 |
* and should be set to -1. |
| 194 |
* |
| 195 |
* Possible values for type are: |
| 196 |
* |
| 197 |
* |
| 198 |
* |
| 199 |
* SQLT_BFILEE or OCI_B_BFILE |
| 200 |
* - for BFILEs; |
| 201 |
* |
| 202 |
* |
| 203 |
* |
| 204 |
* |
| 205 |
* SQLT_CFILEE or OCI_B_CFILEE |
| 206 |
* - for CFILEs; |
| 207 |
* |
| 208 |
* |
| 209 |
* |
| 210 |
* |
| 211 |
* SQLT_CLOB or OCI_B_CLOB |
| 212 |
* - for CLOBs; |
| 213 |
* |
| 214 |
* |
| 215 |
* |
| 216 |
* |
| 217 |
* SQLT_BLOB or OCI_B_BLOB |
| 218 |
* - for BLOBs; |
| 219 |
* |
| 220 |
* |
| 221 |
* |
| 222 |
* |
| 223 |
* SQLT_RDD or OCI_B_ROWID |
| 224 |
* - for ROWIDs; |
| 225 |
* |
| 226 |
* |
| 227 |
* |
| 228 |
* |
| 229 |
* SQLT_NTY or OCI_B_NTY |
| 230 |
* - for named datatypes; |
| 231 |
* |
| 232 |
* |
| 233 |
* |
| 234 |
* |
| 235 |
* SQLT_INT or OCI_B_INT - for integers; |
| 236 |
* |
| 237 |
* |
| 238 |
* |
| 239 |
* |
| 240 |
* SQLT_CHR - for VARCHARs; |
| 241 |
* |
| 242 |
* |
| 243 |
* |
| 244 |
* |
| 245 |
* SQLT_BIN or OCI_B_BIN |
| 246 |
* - for RAW columns; |
| 247 |
* |
| 248 |
* |
| 249 |
* |
| 250 |
* |
| 251 |
* SQLT_LNG - for LONG columns; |
| 252 |
* |
| 253 |
* |
| 254 |
* |
| 255 |
* |
| 256 |
* SQLT_LBI - for LONG RAW columns; |
| 257 |
* |
| 258 |
* |
| 259 |
* |
| 260 |
* |
| 261 |
* SQLT_RSET - for cursors created |
| 262 |
* with oci_new_cursor; |
| 263 |
* |
| 264 |
* |
| 265 |
* |
| 266 |
* |
| 267 |
* SQLT_BOL or OCI_B_BOL |
| 268 |
* - for PL/SQL BOOLEANs (Requires OCI8 2.0.7 and Oracle Database 12c) |
| 269 |
* |
| 270 |
* |
| 271 |
* |
| 272 |
* |
| 273 |
* SQLT_BFILEE or OCI_B_BFILE |
| 274 |
* - for BFILEs; |
| 275 |
* |
| 276 |
* SQLT_CFILEE or OCI_B_CFILEE |
| 277 |
* - for CFILEs; |
| 278 |
* |
| 279 |
* SQLT_CLOB or OCI_B_CLOB |
| 280 |
* - for CLOBs; |
| 281 |
* |
| 282 |
* SQLT_BLOB or OCI_B_BLOB |
| 283 |
* - for BLOBs; |
| 284 |
* |
| 285 |
* SQLT_RDD or OCI_B_ROWID |
| 286 |
* - for ROWIDs; |
| 287 |
* |
| 288 |
* SQLT_NTY or OCI_B_NTY |
| 289 |
* - for named datatypes; |
| 290 |
* |
| 291 |
* SQLT_INT or OCI_B_INT - for integers; |
| 292 |
* |
| 293 |
* SQLT_CHR - for VARCHARs; |
| 294 |
* |
| 295 |
* SQLT_BIN or OCI_B_BIN |
| 296 |
* - for RAW columns; |
| 297 |
* |
| 298 |
* SQLT_LNG - for LONG columns; |
| 299 |
* |
| 300 |
* SQLT_LBI - for LONG RAW columns; |
| 301 |
* |
| 302 |
* SQLT_RSET - for cursors created |
| 303 |
* with oci_new_cursor; |
| 304 |
* |
| 305 |
* SQLT_BOL or OCI_B_BOL |
| 306 |
* - for PL/SQL BOOLEANs (Requires OCI8 2.0.7 and Oracle Database 12c) |
| 307 |
* @throws Oci8Exception |
| 308 |
* |
| 309 |
*/ |
| 310 |
function oci_bind_by_name($statement, string $bv_name, &$variable, int $maxlength = -1, int $type = SQLT_CHR): void |
| 311 |
{ |
| 312 |
error_clear_last(); |
| 313 |
$result = \oci_bind_by_name($statement, $bv_name, $variable, $maxlength, $type); |
| 314 |
if ($result === false) { |
| 315 |
throw Oci8Exception::createFromPhpError(); |
| 316 |
} |
| 317 |
} |
| 318 |
|
| 319 |
|
| 320 |
/** |
| 321 |
* Invalidates a cursor, freeing all associated resources and cancels the |
| 322 |
* ability to read from it. |
| 323 |
* |
| 324 |
* @param resource $statement An OCI statement. |
| 325 |
* @throws Oci8Exception |
| 326 |
* |
| 327 |
*/ |
| 328 |
function oci_cancel($statement): void |
| 329 |
{ |
| 330 |
error_clear_last(); |
| 331 |
$result = \oci_cancel($statement); |
| 332 |
if ($result === false) { |
| 333 |
throw Oci8Exception::createFromPhpError(); |
| 334 |
} |
| 335 |
} |
| 336 |
|
| 337 |
|
| 338 |
/** |
| 339 |
* Unsets connection. The underlying database |
| 340 |
* connection is closed if no other resources are using it and if it |
| 341 |
* was created with oci_connect |
| 342 |
* or oci_new_connect. |
| 343 |
* |
| 344 |
* It is recommended to close connections that are no longer needed |
| 345 |
* because this makes database resources available for other users. |
| 346 |
* |
| 347 |
* @param resource $connection An Oracle connection identifier returned by |
| 348 |
* oci_connect, oci_pconnect, |
| 349 |
* or oci_new_connect. |
| 350 |
* @throws Oci8Exception |
| 351 |
* |
| 352 |
*/ |
| 353 |
function oci_close($connection): void |
| 354 |
{ |
| 355 |
error_clear_last(); |
| 356 |
$result = \oci_close($connection); |
| 357 |
if ($result === false) { |
| 358 |
throw Oci8Exception::createFromPhpError(); |
| 359 |
} |
| 360 |
} |
| 361 |
|
| 362 |
|
| 363 |
/** |
| 364 |
* Commits the outstanding transaction for the |
| 365 |
* Oracle connection. A commit ends the |
| 366 |
* current transaction and makes permanent all changes. It releases |
| 367 |
* all locks held. |
| 368 |
* |
| 369 |
* A transaction begins when the first SQL statement that changes data |
| 370 |
* is executed with oci_execute using |
| 371 |
* the OCI_NO_AUTO_COMMIT flag. Further data |
| 372 |
* changes made by other statements become part of the same |
| 373 |
* transaction. Data changes made in a transaction are temporary |
| 374 |
* until the transaction is committed or rolled back. Other users of |
| 375 |
* the database will not see the changes until they are committed. |
| 376 |
* |
| 377 |
* When inserting or updating data, using transactions is recommended |
| 378 |
* for relational data consistency and for performance reasons. |
| 379 |
* |
| 380 |
* @param resource $connection An Oracle connection identifier, returned by |
| 381 |
* oci_connect, oci_pconnect, or oci_new_connect. |
| 382 |
* @throws Oci8Exception |
| 383 |
* |
| 384 |
*/ |
| 385 |
function oci_commit($connection): void |
| 386 |
{ |
| 387 |
error_clear_last(); |
| 388 |
$result = \oci_commit($connection); |
| 389 |
if ($result === false) { |
| 390 |
throw Oci8Exception::createFromPhpError(); |
| 391 |
} |
| 392 |
} |
| 393 |
|
| 394 |
|
| 395 |
/** |
| 396 |
* Returns a connection identifier needed for most other OCI8 operations. |
| 397 |
* |
| 398 |
* See Connection Handling for |
| 399 |
* general information on connection management and connection |
| 400 |
* pooling. |
| 401 |
* |
| 402 |
* From PHP 5.1.2 (PECL OCI8 1.1) oci_close can |
| 403 |
* be used to close the connection. |
| 404 |
* |
| 405 |
* The second and subsequent calls to oci_connect |
| 406 |
* with the same parameters will return the connection handle returned |
| 407 |
* from the first call. This means that transactions in one handle are |
| 408 |
* also in the other handles, because they use the |
| 409 |
* same underlying database connection. If two |
| 410 |
* handles need to be transactionally isolated from each other, use |
| 411 |
* oci_new_connect instead. |
| 412 |
* |
| 413 |
* @param string $username The Oracle user name. |
| 414 |
* @param string $password The password for username. |
| 415 |
* @param string|null $connection_string Contains |
| 416 |
* the Oracle instance to connect to. It can be |
| 417 |
* an Easy Connect |
| 418 |
* string, or a Connect Name from |
| 419 |
* the tnsnames.ora file, or the name of a local |
| 420 |
* Oracle instance. |
| 421 |
* |
| 422 |
* If not specified, PHP uses |
| 423 |
* environment variables such as TWO_TASK (on Linux) |
| 424 |
* or LOCAL (on Windows) |
| 425 |
* and ORACLE_SID to determine the |
| 426 |
* Oracle instance to connect to. |
| 427 |
* |
| 428 |
* |
| 429 |
* To use the Easy Connect naming method, PHP must be linked with Oracle |
| 430 |
* 10g or greater Client libraries. The Easy Connect string for Oracle |
| 431 |
* 10g is of the form: |
| 432 |
* [//]host_name[:port][/service_name]. From Oracle |
| 433 |
* 11g, the syntax is: |
| 434 |
* [//]host_name[:port][/service_name][:server_type][/instance_name]. |
| 435 |
* Service names can be found by running the Oracle |
| 436 |
* utility lsnrctl status on the database server |
| 437 |
* machine. |
| 438 |
* |
| 439 |
* |
| 440 |
* The tnsnames.ora file can be in the Oracle Net |
| 441 |
* search path, which |
| 442 |
* includes $ORACLE_HOME/network/admin |
| 443 |
* and /etc. Alternatively |
| 444 |
* set TNS_ADMIN so |
| 445 |
* that $TNS_ADMIN/tnsnames.ora is read. Make sure |
| 446 |
* the web daemon has read access to the file. |
| 447 |
* @param string|null $character_set Determines |
| 448 |
* the character set used by the Oracle Client libraries. The character |
| 449 |
* set does not need to match the character set used by the database. If |
| 450 |
* it doesn't match, Oracle will do its best to convert data to and from |
| 451 |
* the database character set. Depending on the character sets this may |
| 452 |
* not give usable results. Conversion also adds some time overhead. |
| 453 |
* |
| 454 |
* If not specified, the |
| 455 |
* Oracle Client libraries determine a character set from |
| 456 |
* the NLS_LANG environment variable. |
| 457 |
* |
| 458 |
* Passing this parameter can |
| 459 |
* reduce the time taken to connect. |
| 460 |
* @param int|null $session_mode This |
| 461 |
* parameter is available since version PHP 5 (PECL OCI8 1.1) and accepts the |
| 462 |
* following values: OCI_DEFAULT, |
| 463 |
* OCI_SYSOPER and OCI_SYSDBA. |
| 464 |
* If either OCI_SYSOPER or |
| 465 |
* OCI_SYSDBA were specified, this function will try |
| 466 |
* to establish privileged connection using external credentials. |
| 467 |
* Privileged connections are disabled by default. To enable them you |
| 468 |
* need to set oci8.privileged_connect |
| 469 |
* to On. |
| 470 |
* |
| 471 |
* |
| 472 |
* PHP 5.3 (PECL OCI8 1.3.4) introduced the |
| 473 |
* OCI_CRED_EXT mode value. This tells Oracle to use |
| 474 |
* External or OS authentication, which must be configured in the |
| 475 |
* database. The OCI_CRED_EXT flag can only be used |
| 476 |
* with username of "/" and a empty password. |
| 477 |
* oci8.privileged_connect |
| 478 |
* may be On or Off. |
| 479 |
* |
| 480 |
* |
| 481 |
* OCI_CRED_EXT may be combined with the |
| 482 |
* OCI_SYSOPER or |
| 483 |
* OCI_SYSDBA modes. |
| 484 |
* |
| 485 |
* |
| 486 |
* OCI_CRED_EXT is not supported on Windows for |
| 487 |
* security reasons. |
| 488 |
* |
| 489 |
* @return resource Returns a connection identifier. |
| 490 |
* @throws Oci8Exception |
| 491 |
* |
| 492 |
*/ |
| 493 |
function oci_connect(string $username, string $password, ?string $connection_string = null, ?string $character_set = null, ?int $session_mode = null) |
| 494 |
{ |
| 495 |
error_clear_last(); |
| 496 |
if ($session_mode !== null) { |
| 497 |
$result = \oci_connect($username, $password, $connection_string, $character_set, $session_mode); |
| 498 |
} elseif ($character_set !== null) { |
| 499 |
$result = \oci_connect($username, $password, $connection_string, $character_set); |
| 500 |
} elseif ($connection_string !== null) { |
| 501 |
$result = \oci_connect($username, $password, $connection_string); |
| 502 |
} else { |
| 503 |
$result = \oci_connect($username, $password); |
| 504 |
} |
| 505 |
if ($result === false) { |
| 506 |
throw Oci8Exception::createFromPhpError(); |
| 507 |
} |
| 508 |
return $result; |
| 509 |
} |
| 510 |
|
| 511 |
|
| 512 |
/** |
| 513 |
* Associates a PHP variable with a column for query fetches using oci_fetch. |
| 514 |
* |
| 515 |
* The oci_define_by_name call must occur before |
| 516 |
* executing oci_execute. |
| 517 |
* |
| 518 |
* @param resource $statement A valid OCI8 statement |
| 519 |
* identifier created by oci_parse and executed |
| 520 |
* by oci_execute, or a REF |
| 521 |
* CURSOR statement identifier. |
| 522 |
* @param string $column_name The column name used in the query. |
| 523 |
* |
| 524 |
* Use uppercase for Oracle's default, non-case sensitive column |
| 525 |
* names. Use the exact column name case for case-sensitive |
| 526 |
* column names. |
| 527 |
* @param mixed $variable The PHP variable that will contain the returned column value. |
| 528 |
* @param int $type The data type to be returned. Generally not needed. Note that |
| 529 |
* Oracle-style data conversions are not performed. For example, |
| 530 |
* SQLT_INT will be ignored and the returned |
| 531 |
* data type will still be SQLT_CHR. |
| 532 |
* |
| 533 |
* You can optionally use oci_new_descriptor |
| 534 |
* to allocate LOB/ROWID/BFILE descriptors. |
| 535 |
* @throws Oci8Exception |
| 536 |
* |
| 537 |
*/ |
| 538 |
function oci_define_by_name($statement, string $column_name, &$variable, int $type = SQLT_CHR): void |
| 539 |
{ |
| 540 |
error_clear_last(); |
| 541 |
$result = \oci_define_by_name($statement, $column_name, $variable, $type); |
| 542 |
if ($result === false) { |
| 543 |
throw Oci8Exception::createFromPhpError(); |
| 544 |
} |
| 545 |
} |
| 546 |
|
| 547 |
|
| 548 |
/** |
| 549 |
* Executes a statement previously returned |
| 550 |
* from oci_parse. |
| 551 |
* |
| 552 |
* After execution, statements like INSERT will |
| 553 |
* have data committed to the database by default. For statements |
| 554 |
* like SELECT, execution performs the logic of the |
| 555 |
* query. Query results can subsequently be fetched in PHP with |
| 556 |
* functions like oci_fetch_array. |
| 557 |
* |
| 558 |
* Each parsed statement may be executed multiple times, saving the |
| 559 |
* cost of re-parsing. This is commonly used |
| 560 |
* for INSERT statements when data is bound |
| 561 |
* with oci_bind_by_name. |
| 562 |
* |
| 563 |
* @param resource $statement A valid OCI statement identifier. |
| 564 |
* @param int $mode An optional second parameter can be one of the following constants: |
| 565 |
* |
| 566 |
* Execution Modes |
| 567 |
* |
| 568 |
* |
| 569 |
* |
| 570 |
* Constant |
| 571 |
* Description |
| 572 |
* |
| 573 |
* |
| 574 |
* |
| 575 |
* |
| 576 |
* OCI_COMMIT_ON_SUCCESS |
| 577 |
* Automatically commit all outstanding changes for |
| 578 |
* this connection when the statement has succeeded. This |
| 579 |
* is the default. |
| 580 |
* |
| 581 |
* |
| 582 |
* OCI_DESCRIBE_ONLY |
| 583 |
* Make query meta data available to functions |
| 584 |
* like oci_field_name but do not |
| 585 |
* create a result set. Any subsequent fetch call such |
| 586 |
* as oci_fetch_array will |
| 587 |
* fail. |
| 588 |
* |
| 589 |
* |
| 590 |
* OCI_NO_AUTO_COMMIT |
| 591 |
* Do not automatically commit changes. Prior to PHP |
| 592 |
* 5.3.2 (PECL OCI8 1.4) |
| 593 |
* use OCI_DEFAULT which is equivalent |
| 594 |
* to OCI_NO_AUTO_COMMIT. |
| 595 |
* |
| 596 |
* |
| 597 |
* |
| 598 |
* |
| 599 |
* |
| 600 |
* Using OCI_NO_AUTO_COMMIT mode starts or continues a |
| 601 |
* transaction. Transactions are automatically rolled back when |
| 602 |
* the connection is closed, or when the script ends. Explicitly |
| 603 |
* call oci_commit to commit a transaction, |
| 604 |
* or oci_rollback to abort it. |
| 605 |
* |
| 606 |
* When inserting or updating data, using transactions is |
| 607 |
* recommended for relational data consistency and for performance |
| 608 |
* reasons. |
| 609 |
* |
| 610 |
* If OCI_NO_AUTO_COMMIT mode is used for any |
| 611 |
* statement including queries, and |
| 612 |
* oci_commit |
| 613 |
* or oci_rollback is not subsequently |
| 614 |
* called, then OCI8 will perform a rollback at the end of the |
| 615 |
* script even if no data was changed. To avoid an unnecessary |
| 616 |
* rollback, many scripts do not |
| 617 |
* use OCI_NO_AUTO_COMMIT mode for queries or |
| 618 |
* PL/SQL. Be careful to ensure the appropriate transactional |
| 619 |
* consistency for the application when |
| 620 |
* using oci_execute with different modes in |
| 621 |
* the same script. |
| 622 |
* @throws Oci8Exception |
| 623 |
* |
| 624 |
*/ |
| 625 |
function oci_execute($statement, int $mode = OCI_COMMIT_ON_SUCCESS): void |
| 626 |
{ |
| 627 |
error_clear_last(); |
| 628 |
$result = \oci_execute($statement, $mode); |
| 629 |
if ($result === false) { |
| 630 |
throw Oci8Exception::createFromPhpError(); |
| 631 |
} |
| 632 |
} |
| 633 |
|
| 634 |
|
| 635 |
/** |
| 636 |
* Fetches multiple rows from a query into a two-dimensional array. |
| 637 |
* By default, all rows are returned. |
| 638 |
* |
| 639 |
* This function can be called only once for each query executed |
| 640 |
* with oci_execute. |
| 641 |
* |
| 642 |
* @param resource $statement A valid OCI8 statement |
| 643 |
* identifier created by oci_parse and executed |
| 644 |
* by oci_execute, or a REF |
| 645 |
* CURSOR statement identifier. |
| 646 |
* @param array|null $output The variable to contain the returned rows. |
| 647 |
* |
| 648 |
* LOB columns are returned as strings, where Oracle supports |
| 649 |
* conversion. |
| 650 |
* |
| 651 |
* See oci_fetch_array for more information |
| 652 |
* on how data and types are fetched. |
| 653 |
* @param int $skip The number of initial rows to discard when fetching the |
| 654 |
* result. The default value is 0, so the first row onwards is |
| 655 |
* returned. |
| 656 |
* @param int $maxrows The number of rows to return. The default is -1 meaning return |
| 657 |
* all the rows from skip + 1 onwards. |
| 658 |
* @param int $flags Parameter flags indicates the array |
| 659 |
* structure and whether associative arrays should be used. |
| 660 |
* |
| 661 |
* oci_fetch_all Array Structure Modes |
| 662 |
* |
| 663 |
* |
| 664 |
* |
| 665 |
* Constant |
| 666 |
* Description |
| 667 |
* |
| 668 |
* |
| 669 |
* |
| 670 |
* |
| 671 |
* OCI_FETCHSTATEMENT_BY_ROW |
| 672 |
* The outer array will contain one sub-array per query |
| 673 |
* row. |
| 674 |
* |
| 675 |
* |
| 676 |
* OCI_FETCHSTATEMENT_BY_COLUMN |
| 677 |
* The outer array will contain one sub-array per query |
| 678 |
* column. This is the default. |
| 679 |
* |
| 680 |
* |
| 681 |
* |
| 682 |
* |
| 683 |
* |
| 684 |
* Arrays can be indexed either by column heading or numerically. |
| 685 |
* Only one index mode will be returned. |
| 686 |
* |
| 687 |
* oci_fetch_all Array Index Modes |
| 688 |
* |
| 689 |
* |
| 690 |
* |
| 691 |
* Constant |
| 692 |
* Description |
| 693 |
* |
| 694 |
* |
| 695 |
* |
| 696 |
* |
| 697 |
* OCI_NUM |
| 698 |
* Numeric indexes are used for each column's array. |
| 699 |
* |
| 700 |
* |
| 701 |
* OCI_ASSOC |
| 702 |
* Associative indexes are used for each column's |
| 703 |
* array. This is the default. |
| 704 |
* |
| 705 |
* |
| 706 |
* |
| 707 |
* |
| 708 |
* |
| 709 |
* Use the addition operator "+" to choose a combination |
| 710 |
* of array structure and index modes. |
| 711 |
* |
| 712 |
* Oracle's default, non-case sensitive column names will have |
| 713 |
* uppercase array keys. Case-sensitive column names will have |
| 714 |
* array keys using the exact column case. |
| 715 |
* Use var_dump |
| 716 |
* on output to verify the appropriate case |
| 717 |
* to use for each query. |
| 718 |
* |
| 719 |
* Queries that have more than one column with the same name |
| 720 |
* should use column aliases. Otherwise only one of the columns |
| 721 |
* will appear in an associative array. |
| 722 |
* @return int Returns the number of rows in output, which |
| 723 |
* may be 0 or more. |
| 724 |
* @throws Oci8Exception |
| 725 |
* |
| 726 |
*/ |
| 727 |
function oci_fetch_all($statement, ?array &$output, int $skip = 0, int $maxrows = -1, int $flags = OCI_FETCHSTATEMENT_BY_COLUMN + OCI_ASSOC): int |
| 728 |
{ |
| 729 |
error_clear_last(); |
| 730 |
$result = \oci_fetch_all($statement, $output, $skip, $maxrows, $flags); |
| 731 |
if ($result === false) { |
| 732 |
throw Oci8Exception::createFromPhpError(); |
| 733 |
} |
| 734 |
return $result; |
| 735 |
} |
| 736 |
|
| 737 |
|
| 738 |
/** |
| 739 |
* Returns the name of the field. |
| 740 |
* |
| 741 |
* @param resource $statement A valid OCI statement identifier. |
| 742 |
* @param mixed $field Can be the field's index (1-based) or name. |
| 743 |
* @return string Returns the name as a strings. |
| 744 |
* @throws Oci8Exception |
| 745 |
* |
| 746 |
*/ |
| 747 |
function oci_field_name($statement, $field): string |
| 748 |
{ |
| 749 |
error_clear_last(); |
| 750 |
$result = \oci_field_name($statement, $field); |
| 751 |
if ($result === false) { |
| 752 |
throw Oci8Exception::createFromPhpError(); |
| 753 |
} |
| 754 |
return $result; |
| 755 |
} |
| 756 |
|
| 757 |
|
| 758 |
/** |
| 759 |
* Returns precision of the field. |
| 760 |
* |
| 761 |
* For FLOAT columns, precision is nonzero and scale is -127. |
| 762 |
* If precision is 0, then column is NUMBER. Else it's |
| 763 |
* NUMBER(precision, scale). |
| 764 |
* |
| 765 |
* @param resource $statement A valid OCI statement identifier. |
| 766 |
* @param mixed $field Can be the field's index (1-based) or name. |
| 767 |
* @return int Returns the precision as an integers. |
| 768 |
* @throws Oci8Exception |
| 769 |
* |
| 770 |
*/ |
| 771 |
function oci_field_precision($statement, $field): int |
| 772 |
{ |
| 773 |
error_clear_last(); |
| 774 |
$result = \oci_field_precision($statement, $field); |
| 775 |
if ($result === false) { |
| 776 |
throw Oci8Exception::createFromPhpError(); |
| 777 |
} |
| 778 |
return $result; |
| 779 |
} |
| 780 |
|
| 781 |
|
| 782 |
/** |
| 783 |
* Returns the scale of the column with field index. |
| 784 |
* |
| 785 |
* For FLOAT columns, precision is nonzero and scale is -127. |
| 786 |
* If precision is 0, then column is NUMBER. Else it's |
| 787 |
* NUMBER(precision, scale). |
| 788 |
* |
| 789 |
* @param resource $statement A valid OCI statement identifier. |
| 790 |
* @param mixed $field Can be the field's index (1-based) or name. |
| 791 |
* @return int Returns the scale as an integers. |
| 792 |
* @throws Oci8Exception |
| 793 |
* |
| 794 |
*/ |
| 795 |
function oci_field_scale($statement, $field): int |
| 796 |
{ |
| 797 |
error_clear_last(); |
| 798 |
$result = \oci_field_scale($statement, $field); |
| 799 |
if ($result === false) { |
| 800 |
throw Oci8Exception::createFromPhpError(); |
| 801 |
} |
| 802 |
return $result; |
| 803 |
} |
| 804 |
|
| 805 |
|
| 806 |
/** |
| 807 |
* Returns the size of a field. |
| 808 |
* |
| 809 |
* @param resource $statement A valid OCI statement identifier. |
| 810 |
* @param mixed $field Can be the field's index (1-based) or name. |
| 811 |
* @return int Returns the size of a field in bytess. |
| 812 |
* @throws Oci8Exception |
| 813 |
* |
| 814 |
*/ |
| 815 |
function oci_field_size($statement, $field): int |
| 816 |
{ |
| 817 |
error_clear_last(); |
| 818 |
$result = \oci_field_size($statement, $field); |
| 819 |
if ($result === false) { |
| 820 |
throw Oci8Exception::createFromPhpError(); |
| 821 |
} |
| 822 |
return $result; |
| 823 |
} |
| 824 |
|
| 825 |
|
| 826 |
/** |
| 827 |
* Returns Oracle's raw "SQLT" data type of the field. |
| 828 |
* |
| 829 |
* If you want a field's type name, then use oci_field_type instead. |
| 830 |
* |
| 831 |
* @param resource $statement A valid OCI statement identifier. |
| 832 |
* @param mixed $field Can be the field's index (1-based) or name. |
| 833 |
* @return int Returns Oracle's raw data type as a numbers. |
| 834 |
* @throws Oci8Exception |
| 835 |
* |
| 836 |
*/ |
| 837 |
function oci_field_type_raw($statement, $field): int |
| 838 |
{ |
| 839 |
error_clear_last(); |
| 840 |
$result = \oci_field_type_raw($statement, $field); |
| 841 |
if ($result === false) { |
| 842 |
throw Oci8Exception::createFromPhpError(); |
| 843 |
} |
| 844 |
return $result; |
| 845 |
} |
| 846 |
|
| 847 |
|
| 848 |
/** |
| 849 |
* Returns a field's data type name. |
| 850 |
* |
| 851 |
* @param resource $statement A valid OCI statement identifier. |
| 852 |
* @param mixed $field Can be the field's index (1-based) or name. |
| 853 |
* @return mixed Returns the field data type as a strings. |
| 854 |
* @throws Oci8Exception |
| 855 |
* |
| 856 |
*/ |
| 857 |
function oci_field_type($statement, $field) |
| 858 |
{ |
| 859 |
error_clear_last(); |
| 860 |
$result = \oci_field_type($statement, $field); |
| 861 |
if ($result === false) { |
| 862 |
throw Oci8Exception::createFromPhpError(); |
| 863 |
} |
| 864 |
return $result; |
| 865 |
} |
| 866 |
|
| 867 |
|
| 868 |
/** |
| 869 |
* Frees a descriptor allocated by oci_new_descriptor. |
| 870 |
* |
| 871 |
* @param resource $descriptor |
| 872 |
* @throws Oci8Exception |
| 873 |
* |
| 874 |
*/ |
| 875 |
function oci_free_descriptor($descriptor): void |
| 876 |
{ |
| 877 |
error_clear_last(); |
| 878 |
$result = \oci_free_descriptor($descriptor); |
| 879 |
if ($result === false) { |
| 880 |
throw Oci8Exception::createFromPhpError(); |
| 881 |
} |
| 882 |
} |
| 883 |
|
| 884 |
|
| 885 |
/** |
| 886 |
* Frees resources associated with Oracle's cursor or statement, which was |
| 887 |
* received from as a result of oci_parse or obtained |
| 888 |
* from Oracle. |
| 889 |
* |
| 890 |
* @param resource $statement A valid OCI statement identifier. |
| 891 |
* @throws Oci8Exception |
| 892 |
* |
| 893 |
*/ |
| 894 |
function oci_free_statement($statement): void |
| 895 |
{ |
| 896 |
error_clear_last(); |
| 897 |
$result = \oci_free_statement($statement); |
| 898 |
if ($result === false) { |
| 899 |
throw Oci8Exception::createFromPhpError(); |
| 900 |
} |
| 901 |
} |
| 902 |
|
| 903 |
|
| 904 |
/** |
| 905 |
* Allocates a new collection object. |
| 906 |
* |
| 907 |
* @param resource $connection An Oracle connection identifier, returned by |
| 908 |
* oci_connect or oci_pconnect. |
| 909 |
* @param string $tdo Should be a valid named type (uppercase). |
| 910 |
* @param string|null $schema Should point to the scheme, where the named type was created. The name |
| 911 |
* of the current user is the default value. |
| 912 |
* |
| 913 |
* @return \OCI-Collection Returns a new OCICollection object. |
| 914 |
* @throws Oci8Exception |
| 915 |
* |
| 916 |
*/ |
| 917 |
function oci_new_collection($connection, string $tdo, ?string $schema = null) |
| 918 |
{ |
| 919 |
error_clear_last(); |
| 920 |
$result = \oci_new_collection($connection, $tdo, $schema); |
| 921 |
if ($result === false) { |
| 922 |
throw Oci8Exception::createFromPhpError(); |
| 923 |
} |
| 924 |
return $result; |
| 925 |
} |
| 926 |
|
| 927 |
|
| 928 |
/** |
| 929 |
* Establishes a new connection to an Oracle server and logs on. |
| 930 |
* |
| 931 |
* Unlike oci_connect and |
| 932 |
* oci_pconnect, oci_new_connect |
| 933 |
* does not cache connections and will always return a brand-new freshly |
| 934 |
* opened connection handle. This is useful if your application needs |
| 935 |
* transactional isolation between two sets of queries. |
| 936 |
* |
| 937 |
* @param string $username The Oracle user name. |
| 938 |
* @param string $password The password for username. |
| 939 |
* @param string|null $connection_string Contains |
| 940 |
* the Oracle instance to connect to. It can be |
| 941 |
* an Easy Connect |
| 942 |
* string, or a Connect Name from |
| 943 |
* the tnsnames.ora file, or the name of a local |
| 944 |
* Oracle instance. |
| 945 |
* |
| 946 |
* If not specified, PHP uses |
| 947 |
* environment variables such as TWO_TASK (on Linux) |
| 948 |
* or LOCAL (on Windows) |
| 949 |
* and ORACLE_SID to determine the |
| 950 |
* Oracle instance to connect to. |
| 951 |
* |
| 952 |
* |
| 953 |
* To use the Easy Connect naming method, PHP must be linked with Oracle |
| 954 |
* 10g or greater Client libraries. The Easy Connect string for Oracle |
| 955 |
* 10g is of the form: |
| 956 |
* [//]host_name[:port][/service_name]. From Oracle |
| 957 |
* 11g, the syntax is: |
| 958 |
* [//]host_name[:port][/service_name][:server_type][/instance_name]. |
| 959 |
* Service names can be found by running the Oracle |
| 960 |
* utility lsnrctl status on the database server |
| 961 |
* machine. |
| 962 |
* |
| 963 |
* |
| 964 |
* The tnsnames.ora file can be in the Oracle Net |
| 965 |
* search path, which |
| 966 |
* includes $ORACLE_HOME/network/admin |
| 967 |
* and /etc. Alternatively |
| 968 |
* set TNS_ADMIN so |
| 969 |
* that $TNS_ADMIN/tnsnames.ora is read. Make sure |
| 970 |
* the web daemon has read access to the file. |
| 971 |
* @param string|null $character_set Determines |
| 972 |
* the character set used by the Oracle Client libraries. The character |
| 973 |
* set does not need to match the character set used by the database. If |
| 974 |
* it doesn't match, Oracle will do its best to convert data to and from |
| 975 |
* the database character set. Depending on the character sets this may |
| 976 |
* not give usable results. Conversion also adds some time overhead. |
| 977 |
* |
| 978 |
* If not specified, the |
| 979 |
* Oracle Client libraries determine a character set from |
| 980 |
* the NLS_LANG environment variable. |
| 981 |
* |
| 982 |
* Passing this parameter can |
| 983 |
* reduce the time taken to connect. |
| 984 |
* @param int|null $session_mode This |
| 985 |
* parameter is available since version PHP 5 (PECL OCI8 1.1) and accepts the |
| 986 |
* following values: OCI_DEFAULT, |
| 987 |
* OCI_SYSOPER and OCI_SYSDBA. |
| 988 |
* If either OCI_SYSOPER or |
| 989 |
* OCI_SYSDBA were specified, this function will try |
| 990 |
* to establish privileged connection using external credentials. |
| 991 |
* Privileged connections are disabled by default. To enable them you |
| 992 |
* need to set oci8.privileged_connect |
| 993 |
* to On. |
| 994 |
* |
| 995 |
* |
| 996 |
* PHP 5.3 (PECL OCI8 1.3.4) introduced the |
| 997 |
* OCI_CRED_EXT mode value. This tells Oracle to use |
| 998 |
* External or OS authentication, which must be configured in the |
| 999 |
* database. The OCI_CRED_EXT flag can only be used |
| 1000 |
* with username of "/" and a empty password. |
| 1001 |
* oci8.privileged_connect |
| 1002 |
* may be On or Off. |
| 1003 |
* |
| 1004 |
* |
| 1005 |
* OCI_CRED_EXT may be combined with the |
| 1006 |
* OCI_SYSOPER or |
| 1007 |
* OCI_SYSDBA modes. |
| 1008 |
* |
| 1009 |
* |
| 1010 |
* OCI_CRED_EXT is not supported on Windows for |
| 1011 |
* security reasons. |
| 1012 |
* |
| 1013 |
* @return resource Returns a connection identifier. |
| 1014 |
* @throws Oci8Exception |
| 1015 |
* |
| 1016 |
*/ |
| 1017 |
function oci_new_connect(string $username, string $password, ?string $connection_string = null, ?string $character_set = null, ?int $session_mode = null) |
| 1018 |
{ |
| 1019 |
error_clear_last(); |
| 1020 |
if ($session_mode !== null) { |
| 1021 |
$result = \oci_new_connect($username, $password, $connection_string, $character_set, $session_mode); |
| 1022 |
} elseif ($character_set !== null) { |
| 1023 |
$result = \oci_new_connect($username, $password, $connection_string, $character_set); |
| 1024 |
} elseif ($connection_string !== null) { |
| 1025 |
$result = \oci_new_connect($username, $password, $connection_string); |
| 1026 |
} else { |
| 1027 |
$result = \oci_new_connect($username, $password); |
| 1028 |
} |
| 1029 |
if ($result === false) { |
| 1030 |
throw Oci8Exception::createFromPhpError(); |
| 1031 |
} |
| 1032 |
return $result; |
| 1033 |
} |
| 1034 |
|
| 1035 |
|
| 1036 |
/** |
| 1037 |
* Allocates a new statement handle on the specified connection. |
| 1038 |
* |
| 1039 |
* @param resource $connection An Oracle connection identifier, returned by |
| 1040 |
* oci_connect or oci_pconnect. |
| 1041 |
* @return resource Returns a new statement handle. |
| 1042 |
* @throws Oci8Exception |
| 1043 |
* |
| 1044 |
*/ |
| 1045 |
function oci_new_cursor($connection) |
| 1046 |
{ |
| 1047 |
error_clear_last(); |
| 1048 |
$result = \oci_new_cursor($connection); |
| 1049 |
if ($result === false) { |
| 1050 |
throw Oci8Exception::createFromPhpError(); |
| 1051 |
} |
| 1052 |
return $result; |
| 1053 |
} |
| 1054 |
|
| 1055 |
|
| 1056 |
/** |
| 1057 |
* Allocates resources to hold descriptor or LOB locator. |
| 1058 |
* |
| 1059 |
* @param resource $connection An Oracle connection identifier, returned by |
| 1060 |
* oci_connect or oci_pconnect. |
| 1061 |
* @param int $type Valid values for type are: |
| 1062 |
* OCI_DTYPE_FILE, OCI_DTYPE_LOB and |
| 1063 |
* OCI_DTYPE_ROWID. |
| 1064 |
* @return \OCI-Lob Returns a new LOB or FILE descriptor on success, FALSE on error. |
| 1065 |
* @throws Oci8Exception |
| 1066 |
* |
| 1067 |
*/ |
| 1068 |
function oci_new_descriptor($connection, int $type = OCI_DTYPE_LOB) |
| 1069 |
{ |
| 1070 |
error_clear_last(); |
| 1071 |
$result = \oci_new_descriptor($connection, $type); |
| 1072 |
if ($result === false) { |
| 1073 |
throw Oci8Exception::createFromPhpError(); |
| 1074 |
} |
| 1075 |
return $result; |
| 1076 |
} |
| 1077 |
|
| 1078 |
|
| 1079 |
/** |
| 1080 |
* Gets the number of columns in the given statement. |
| 1081 |
* |
| 1082 |
* @param resource $statement A valid OCI statement identifier. |
| 1083 |
* @return int Returns the number of columns as an integers. |
| 1084 |
* @throws Oci8Exception |
| 1085 |
* |
| 1086 |
*/ |
| 1087 |
function oci_num_fields($statement): int |
| 1088 |
{ |
| 1089 |
error_clear_last(); |
| 1090 |
$result = \oci_num_fields($statement); |
| 1091 |
if ($result === false) { |
| 1092 |
throw Oci8Exception::createFromPhpError(); |
| 1093 |
} |
| 1094 |
return $result; |
| 1095 |
} |
| 1096 |
|
| 1097 |
|
| 1098 |
/** |
| 1099 |
* Gets the number of rows affected during statement execution. |
| 1100 |
* |
| 1101 |
* @param resource $statement A valid OCI statement identifier. |
| 1102 |
* @return int Returns the number of rows affected as an integers. |
| 1103 |
* @throws Oci8Exception |
| 1104 |
* |
| 1105 |
*/ |
| 1106 |
function oci_num_rows($statement): int |
| 1107 |
{ |
| 1108 |
error_clear_last(); |
| 1109 |
$result = \oci_num_rows($statement); |
| 1110 |
if ($result === false) { |
| 1111 |
throw Oci8Exception::createFromPhpError(); |
| 1112 |
} |
| 1113 |
return $result; |
| 1114 |
} |
| 1115 |
|
| 1116 |
|
| 1117 |
/** |
| 1118 |
* Prepares sql_text using |
| 1119 |
* connection and returns the statement identifier, |
| 1120 |
* which can be used with oci_bind_by_name, |
| 1121 |
* oci_execute and other functions. |
| 1122 |
* |
| 1123 |
* Statement identifiers can be freed |
| 1124 |
* with oci_free_statement or by setting the |
| 1125 |
* variable to NULL. |
| 1126 |
* |
| 1127 |
* @param resource $connection An Oracle connection identifier, returned by |
| 1128 |
* oci_connect, oci_pconnect, or oci_new_connect. |
| 1129 |
* @param string $sql_text The SQL or PL/SQL statement. |
| 1130 |
* |
| 1131 |
* SQL statements should not end with a |
| 1132 |
* semi-colon (";"). PL/SQL |
| 1133 |
* statements should end with a semi-colon |
| 1134 |
* (";"). |
| 1135 |
* @return resource Returns a statement handle on success. |
| 1136 |
* @throws Oci8Exception |
| 1137 |
* |
| 1138 |
*/ |
| 1139 |
function oci_parse($connection, string $sql_text) |
| 1140 |
{ |
| 1141 |
error_clear_last(); |
| 1142 |
$result = \oci_parse($connection, $sql_text); |
| 1143 |
if ($result === false) { |
| 1144 |
throw Oci8Exception::createFromPhpError(); |
| 1145 |
} |
| 1146 |
return $result; |
| 1147 |
} |
| 1148 |
|
| 1149 |
|
| 1150 |
/** |
| 1151 |
* Creates a persistent connection to an Oracle server and logs on. |
| 1152 |
* |
| 1153 |
* Persistent connections are cached and re-used between requests, resulting |
| 1154 |
* in reduced overhead on each page load; a typical PHP application will have |
| 1155 |
* a single persistent connection open against an Oracle server per Apache |
| 1156 |
* child process (or PHP FastCGI/CGI process). See the Persistent Database |
| 1157 |
* Connections section for more information. |
| 1158 |
* |
| 1159 |
* @param string $username The Oracle user name. |
| 1160 |
* @param string $password The password for username. |
| 1161 |
* @param string|null $connection_string Contains |
| 1162 |
* the Oracle instance to connect to. It can be |
| 1163 |
* an Easy Connect |
| 1164 |
* string, or a Connect Name from |
| 1165 |
* the tnsnames.ora file, or the name of a local |
| 1166 |
* Oracle instance. |
| 1167 |
* |
| 1168 |
* If not specified, PHP uses |
| 1169 |
* environment variables such as TWO_TASK (on Linux) |
| 1170 |
* or LOCAL (on Windows) |
| 1171 |
* and ORACLE_SID to determine the |
| 1172 |
* Oracle instance to connect to. |
| 1173 |
* |
| 1174 |
* |
| 1175 |
* To use the Easy Connect naming method, PHP must be linked with Oracle |
| 1176 |
* 10g or greater Client libraries. The Easy Connect string for Oracle |
| 1177 |
* 10g is of the form: |
| 1178 |
* [//]host_name[:port][/service_name]. From Oracle |
| 1179 |
* 11g, the syntax is: |
| 1180 |
* [//]host_name[:port][/service_name][:server_type][/instance_name]. |
| 1181 |
* Service names can be found by running the Oracle |
| 1182 |
* utility lsnrctl status on the database server |
| 1183 |
* machine. |
| 1184 |
* |
| 1185 |
* |
| 1186 |
* The tnsnames.ora file can be in the Oracle Net |
| 1187 |
* search path, which |
| 1188 |
* includes $ORACLE_HOME/network/admin |
| 1189 |
* and /etc. Alternatively |
| 1190 |
* set TNS_ADMIN so |
| 1191 |
* that $TNS_ADMIN/tnsnames.ora is read. Make sure |
| 1192 |
* the web daemon has read access to the file. |
| 1193 |
* @param string|null $character_set Determines |
| 1194 |
* the character set used by the Oracle Client libraries. The character |
| 1195 |
* set does not need to match the character set used by the database. If |
| 1196 |
* it doesn't match, Oracle will do its best to convert data to and from |
| 1197 |
* the database character set. Depending on the character sets this may |
| 1198 |
* not give usable results. Conversion also adds some time overhead. |
| 1199 |
* |
| 1200 |
* If not specified, the |
| 1201 |
* Oracle Client libraries determine a character set from |
| 1202 |
* the NLS_LANG environment variable. |
| 1203 |
* |
| 1204 |
* Passing this parameter can |
| 1205 |
* reduce the time taken to connect. |
| 1206 |
* @param int|null $session_mode This |
| 1207 |
* parameter is available since version PHP 5 (PECL OCI8 1.1) and accepts the |
| 1208 |
* following values: OCI_DEFAULT, |
| 1209 |
* OCI_SYSOPER and OCI_SYSDBA. |
| 1210 |
* If either OCI_SYSOPER or |
| 1211 |
* OCI_SYSDBA were specified, this function will try |
| 1212 |
* to establish privileged connection using external credentials. |
| 1213 |
* Privileged connections are disabled by default. To enable them you |
| 1214 |
* need to set oci8.privileged_connect |
| 1215 |
* to On. |
| 1216 |
* |
| 1217 |
* |
| 1218 |
* PHP 5.3 (PECL OCI8 1.3.4) introduced the |
| 1219 |
* OCI_CRED_EXT mode value. This tells Oracle to use |
| 1220 |
* External or OS authentication, which must be configured in the |
| 1221 |
* database. The OCI_CRED_EXT flag can only be used |
| 1222 |
* with username of "/" and a empty password. |
| 1223 |
* oci8.privileged_connect |
| 1224 |
* may be On or Off. |
| 1225 |
* |
| 1226 |
* |
| 1227 |
* OCI_CRED_EXT may be combined with the |
| 1228 |
* OCI_SYSOPER or |
| 1229 |
* OCI_SYSDBA modes. |
| 1230 |
* |
| 1231 |
* |
| 1232 |
* OCI_CRED_EXT is not supported on Windows for |
| 1233 |
* security reasons. |
| 1234 |
* |
| 1235 |
* @return resource Returns a connection identifier. |
| 1236 |
* @throws Oci8Exception |
| 1237 |
* |
| 1238 |
*/ |
| 1239 |
function oci_pconnect(string $username, string $password, ?string $connection_string = null, ?string $character_set = null, ?int $session_mode = null) |
| 1240 |
{ |
| 1241 |
error_clear_last(); |
| 1242 |
if ($session_mode !== null) { |
| 1243 |
$result = \oci_pconnect($username, $password, $connection_string, $character_set, $session_mode); |
| 1244 |
} elseif ($character_set !== null) { |
| 1245 |
$result = \oci_pconnect($username, $password, $connection_string, $character_set); |
| 1246 |
} elseif ($connection_string !== null) { |
| 1247 |
$result = \oci_pconnect($username, $password, $connection_string); |
| 1248 |
} else { |
| 1249 |
$result = \oci_pconnect($username, $password); |
| 1250 |
} |
| 1251 |
if ($result === false) { |
| 1252 |
throw Oci8Exception::createFromPhpError(); |
| 1253 |
} |
| 1254 |
return $result; |
| 1255 |
} |
| 1256 |
|
| 1257 |
|
| 1258 |
/** |
| 1259 |
* Returns the data from field in the current row, |
| 1260 |
* fetched by oci_fetch. |
| 1261 |
* |
| 1262 |
* For details on the data type mapping performed by |
| 1263 |
* the OCI8 extension, see the datatypes |
| 1264 |
* supported by the driver |
| 1265 |
* |
| 1266 |
* @param resource $statement |
| 1267 |
* @param mixed $field Can be either use the column number (1-based) or the column name. |
| 1268 |
* The case of the column name must be the case that Oracle meta data |
| 1269 |
* describes the column as, which is uppercase for columns created |
| 1270 |
* case insensitively. |
| 1271 |
* @return string Returns everything as strings except for abstract types (ROWIDs, LOBs and |
| 1272 |
* FILEs). |
| 1273 |
* @throws Oci8Exception |
| 1274 |
* |
| 1275 |
*/ |
| 1276 |
function oci_result($statement, $field): string |
| 1277 |
{ |
| 1278 |
error_clear_last(); |
| 1279 |
$result = \oci_result($statement, $field); |
| 1280 |
if ($result === false) { |
| 1281 |
throw Oci8Exception::createFromPhpError(); |
| 1282 |
} |
| 1283 |
return $result; |
| 1284 |
} |
| 1285 |
|
| 1286 |
|
| 1287 |
/** |
| 1288 |
* Reverts all uncommitted changes for the Oracle |
| 1289 |
* connection and ends the transaction. It |
| 1290 |
* releases all locks held. All Oracle SAVEPOINTS |
| 1291 |
* are erased. |
| 1292 |
* |
| 1293 |
* A transaction begins when the first SQL statement that changes data |
| 1294 |
* is executed with oci_execute using |
| 1295 |
* the OCI_NO_AUTO_COMMIT flag. Further data |
| 1296 |
* changes made by other statements become part of the same |
| 1297 |
* transaction. Data changes made in a transaction are temporary |
| 1298 |
* until the transaction is committed or rolled back. Other users of |
| 1299 |
* the database will not see the changes until they are committed. |
| 1300 |
* |
| 1301 |
* When inserting or updating data, using transactions is recommended |
| 1302 |
* for relational data consistency and for performance reasons. |
| 1303 |
* |
| 1304 |
* @param resource $connection An Oracle connection identifier, returned by |
| 1305 |
* oci_connect, oci_pconnect |
| 1306 |
* or oci_new_connect. |
| 1307 |
* @throws Oci8Exception |
| 1308 |
* |
| 1309 |
*/ |
| 1310 |
function oci_rollback($connection): void |
| 1311 |
{ |
| 1312 |
error_clear_last(); |
| 1313 |
$result = \oci_rollback($connection); |
| 1314 |
if ($result === false) { |
| 1315 |
throw Oci8Exception::createFromPhpError(); |
| 1316 |
} |
| 1317 |
} |
| 1318 |
|
| 1319 |
|
| 1320 |
/** |
| 1321 |
* Returns a string with the Oracle Database version and available options |
| 1322 |
* |
| 1323 |
* @param resource $connection |
| 1324 |
* @return string Returns the version information as a string. |
| 1325 |
* @throws Oci8Exception |
| 1326 |
* |
| 1327 |
*/ |
| 1328 |
function oci_server_version($connection): string |
| 1329 |
{ |
| 1330 |
error_clear_last(); |
| 1331 |
$result = \oci_server_version($connection); |
| 1332 |
if ($result === false) { |
| 1333 |
throw Oci8Exception::createFromPhpError(); |
| 1334 |
} |
| 1335 |
return $result; |
| 1336 |
} |
| 1337 |
|
| 1338 |
|
| 1339 |
/** |
| 1340 |
* Sets the action name for Oracle tracing. |
| 1341 |
* |
| 1342 |
* The action name is registered with the database when the next |
| 1343 |
* 'round-trip' from PHP to the database occurs, typically when an SQL |
| 1344 |
* statement is executed. |
| 1345 |
* |
| 1346 |
* The action name can subsequently be queried from database administration |
| 1347 |
* views such as V$SESSION. It can be used for |
| 1348 |
* tracing and monitoring such as with V$SQLAREA |
| 1349 |
* and DBMS_MONITOR.SERV_MOD_ACT_STAT_ENABLE. |
| 1350 |
* |
| 1351 |
* The value may be retained across persistent connections. |
| 1352 |
* |
| 1353 |
* @param resource $connection An Oracle connection identifier, |
| 1354 |
* returned by oci_connect, oci_pconnect, |
| 1355 |
* or oci_new_connect. |
| 1356 |
* @param string $action_name User chosen string up to 32 bytes long. |
| 1357 |
* @throws Oci8Exception |
| 1358 |
* |
| 1359 |
*/ |
| 1360 |
function oci_set_action($connection, string $action_name): void |
| 1361 |
{ |
| 1362 |
error_clear_last(); |
| 1363 |
$result = \oci_set_action($connection, $action_name); |
| 1364 |
if ($result === false) { |
| 1365 |
throw Oci8Exception::createFromPhpError(); |
| 1366 |
} |
| 1367 |
} |
| 1368 |
|
| 1369 |
|
| 1370 |
/** |
| 1371 |
* Sets a timeout limiting the maxium time a database round-trip using this connection may take. |
| 1372 |
* |
| 1373 |
* Each OCI8 operation may make zero or more calls to Oracle's client |
| 1374 |
* library. These internal calls may then may make zero or more |
| 1375 |
* round-trips to Oracle Database. If any one of those round-trips |
| 1376 |
* takes more than time_out milliseconds, then the |
| 1377 |
* operation is cancelled and an error is returned to the application. |
| 1378 |
* |
| 1379 |
* The time_out value applies to each round-trip |
| 1380 |
* individually, not to the sum of all round-trips. Time spent |
| 1381 |
* processing in PHP OCI8 before or after the completion of each |
| 1382 |
* round-trip is not counted. |
| 1383 |
* |
| 1384 |
* When a call is interrupted, Oracle will attempt to clean up the |
| 1385 |
* connection for reuse. This operation is allowed to run for |
| 1386 |
* another time_out period. Depending on the |
| 1387 |
* outcome of the cleanup, the connection may or may not be reusable. |
| 1388 |
* |
| 1389 |
* When persistent connections are used, the timeout value will be |
| 1390 |
* retained across PHP requests. |
| 1391 |
* |
| 1392 |
* The oci_set_call_timeout function is available |
| 1393 |
* when OCI8 uses Oracle 18 (or later) Client libraries. |
| 1394 |
* |
| 1395 |
* @param resource $connection An Oracle connection identifier, |
| 1396 |
* returned by oci_connect, oci_pconnect, |
| 1397 |
* or oci_new_connect. |
| 1398 |
* @param int $time_out The maximum time in milliseconds that any single round-trip between PHP and Oracle Database may take. |
| 1399 |
* @throws Oci8Exception |
| 1400 |
* |
| 1401 |
*/ |
| 1402 |
function oci_set_call_timeout($connection, int $time_out): void |
| 1403 |
{ |
| 1404 |
error_clear_last(); |
| 1405 |
$result = \oci_set_call_timeout($connection, $time_out); |
| 1406 |
if ($result === false) { |
| 1407 |
throw Oci8Exception::createFromPhpError(); |
| 1408 |
} |
| 1409 |
} |
| 1410 |
|
| 1411 |
|
| 1412 |
/** |
| 1413 |
* Sets the client identifier used by various database components to |
| 1414 |
* identify lightweight application users who authenticate as the same |
| 1415 |
* database user. |
| 1416 |
* |
| 1417 |
* The client identifier is registered with the database when the next |
| 1418 |
* 'round-trip' from PHP to the database occurs, typically when an SQL |
| 1419 |
* statement is executed. |
| 1420 |
* |
| 1421 |
* The identifier can subsequently be queried, for example |
| 1422 |
* with SELECT SYS_CONTEXT('USERENV','CLIENT_IDENTIFIER') |
| 1423 |
* FROM DUAL. Database administration views such |
| 1424 |
* as V$SESSION will also contain the value. It |
| 1425 |
* can be used with DBMS_MONITOR.CLIENT_ID_TRACE_ENABLE |
| 1426 |
* for tracing and can also be used for auditing. |
| 1427 |
* |
| 1428 |
* The value may be retained across page requests that use the same persistent connection. |
| 1429 |
* |
| 1430 |
* @param resource $connection An Oracle connection identifier, |
| 1431 |
* returned by oci_connect, oci_pconnect, |
| 1432 |
* or oci_new_connect. |
| 1433 |
* @param string $client_identifier User chosen string up to 64 bytes long. |
| 1434 |
* @throws Oci8Exception |
| 1435 |
* |
| 1436 |
*/ |
| 1437 |
function oci_set_client_identifier($connection, string $client_identifier): void |
| 1438 |
{ |
| 1439 |
error_clear_last(); |
| 1440 |
$result = \oci_set_client_identifier($connection, $client_identifier); |
| 1441 |
if ($result === false) { |
| 1442 |
throw Oci8Exception::createFromPhpError(); |
| 1443 |
} |
| 1444 |
} |
| 1445 |
|
| 1446 |
|
| 1447 |
/** |
| 1448 |
* Sets the client information for Oracle tracing. |
| 1449 |
* |
| 1450 |
* The client information is registered with the database when the next |
| 1451 |
* 'round-trip' from PHP to the database occurs, typically when an SQL |
| 1452 |
* statement is executed. |
| 1453 |
* |
| 1454 |
* The client information can subsequently be queried from database |
| 1455 |
* administration views such as V$SESSION. |
| 1456 |
* |
| 1457 |
* The value may be retained across persistent connections. |
| 1458 |
* |
| 1459 |
* @param resource $connection An Oracle connection identifier, |
| 1460 |
* returned by oci_connect, oci_pconnect, |
| 1461 |
* or oci_new_connect. |
| 1462 |
* @param string $client_info User chosen string up to 64 bytes long. |
| 1463 |
* @throws Oci8Exception |
| 1464 |
* |
| 1465 |
*/ |
| 1466 |
function oci_set_client_info($connection, string $client_info): void |
| 1467 |
{ |
| 1468 |
error_clear_last(); |
| 1469 |
$result = \oci_set_client_info($connection, $client_info); |
| 1470 |
if ($result === false) { |
| 1471 |
throw Oci8Exception::createFromPhpError(); |
| 1472 |
} |
| 1473 |
} |
| 1474 |
|
| 1475 |
|
| 1476 |
/** |
| 1477 |
* Sets the DBOP for Oracle tracing. |
| 1478 |
* |
| 1479 |
* The database operation name is registered with the database when the next |
| 1480 |
* 'round-trip' from PHP to the database occurs, typically when a SQL |
| 1481 |
* statement is executed. |
| 1482 |
* |
| 1483 |
* The database operation can subsequently be queried from database administration |
| 1484 |
* views such as V$SQL_MONITOR. |
| 1485 |
* |
| 1486 |
* The oci_set_db_operation function is available |
| 1487 |
* when OCI8 uses Oracle 12 (or later) Client libraries and Oracle Database 12 (or later). |
| 1488 |
* |
| 1489 |
* @param resource $connection An Oracle connection identifier, |
| 1490 |
* returned by oci_connect, oci_pconnect, |
| 1491 |
* or oci_new_connect. |
| 1492 |
* @param string $dbop User chosen string. |
| 1493 |
* @throws Oci8Exception |
| 1494 |
* |
| 1495 |
*/ |
| 1496 |
function oci_set_db_operation($connection, string $dbop): void |
| 1497 |
{ |
| 1498 |
error_clear_last(); |
| 1499 |
$result = \oci_set_db_operation($connection, $dbop); |
| 1500 |
if ($result === false) { |
| 1501 |
throw Oci8Exception::createFromPhpError(); |
| 1502 |
} |
| 1503 |
} |
| 1504 |
|
| 1505 |
|
| 1506 |
/** |
| 1507 |
* Sets the database "edition" of objects to be used by a subsequent |
| 1508 |
* connections. |
| 1509 |
* |
| 1510 |
* Oracle Editions allow concurrent versions of applications to run |
| 1511 |
* using the same schema and object names. This is useful for |
| 1512 |
* upgrading live systems. |
| 1513 |
* |
| 1514 |
* Call oci_set_edition before calling |
| 1515 |
* oci_connect, oci_pconnect |
| 1516 |
* or oci_new_connect. |
| 1517 |
* |
| 1518 |
* If an edition is set that is not valid in the database, connection |
| 1519 |
* will fail even if oci_set_edition returns success. |
| 1520 |
* |
| 1521 |
* When using persistent connections, if a connection with the |
| 1522 |
* requested edition setting already exists, it is reused. Otherwise, |
| 1523 |
* a different persistent connection is created |
| 1524 |
* |
| 1525 |
* @param string $edition Oracle Database edition name previously created with the SQL |
| 1526 |
* "CREATE EDITION" command. |
| 1527 |
* @throws Oci8Exception |
| 1528 |
* |
| 1529 |
*/ |
| 1530 |
function oci_set_edition(string $edition): void |
| 1531 |
{ |
| 1532 |
error_clear_last(); |
| 1533 |
$result = \oci_set_edition($edition); |
| 1534 |
if ($result === false) { |
| 1535 |
throw Oci8Exception::createFromPhpError(); |
| 1536 |
} |
| 1537 |
} |
| 1538 |
|
| 1539 |
|
| 1540 |
/** |
| 1541 |
* Sets the module name for Oracle tracing. |
| 1542 |
* |
| 1543 |
* The module name is registered with the database when the next |
| 1544 |
* 'round-trip' from PHP to the database occurs, typically when an SQL |
| 1545 |
* statement is executed. |
| 1546 |
* |
| 1547 |
* The name can subsequently be queried from database administration |
| 1548 |
* views such as V$SESSION. It can be used for |
| 1549 |
* tracing and monitoring such as with V$SQLAREA |
| 1550 |
* and DBMS_MONITOR.SERV_MOD_ACT_STAT_ENABLE. |
| 1551 |
* |
| 1552 |
* The value may be retained across persistent connections. |
| 1553 |
* |
| 1554 |
* @param resource $connection An Oracle connection identifier, |
| 1555 |
* returned by oci_connect, oci_pconnect, |
| 1556 |
* or oci_new_connect. |
| 1557 |
* @param string $module_name User chosen string up to 48 bytes long. |
| 1558 |
* @throws Oci8Exception |
| 1559 |
* |
| 1560 |
*/ |
| 1561 |
function oci_set_module_name($connection, string $module_name): void |
| 1562 |
{ |
| 1563 |
error_clear_last(); |
| 1564 |
$result = \oci_set_module_name($connection, $module_name); |
| 1565 |
if ($result === false) { |
| 1566 |
throw Oci8Exception::createFromPhpError(); |
| 1567 |
} |
| 1568 |
} |
| 1569 |
|
| 1570 |
|
| 1571 |
/** |
| 1572 |
* Sets the number of rows to be buffered by the Oracle Client |
| 1573 |
* libraries after a successful query call |
| 1574 |
* to oci_execute and for each subsequent |
| 1575 |
* internal fetch request to the database. For queries returning a |
| 1576 |
* large number of rows, performance can be significantly improved by |
| 1577 |
* increasing the prefetch count above the |
| 1578 |
* default oci8.default_prefetch |
| 1579 |
* value. |
| 1580 |
* |
| 1581 |
* Prefetching is Oracle's efficient way of returning more than one |
| 1582 |
* data row from the database in each network request. This can |
| 1583 |
* result in better network and CPU utilization. The buffering of |
| 1584 |
* rows is internal to OCI8 and the behavior of OCI8 fetching |
| 1585 |
* functions is unchanged regardless of the prefetch count. For |
| 1586 |
* example, oci_fetch_row will always return one |
| 1587 |
* row. The prefetch buffer is per-statement and is not used by |
| 1588 |
* re-executed statements or by other connections. |
| 1589 |
* |
| 1590 |
* Call oci_set_prefetch before |
| 1591 |
* calling oci_execute. |
| 1592 |
* |
| 1593 |
* A tuning goal is to set the prefetch value to a reasonable size for |
| 1594 |
* the network and database to handle. For queries returning a very |
| 1595 |
* large number of rows, overall system efficiency might be better if |
| 1596 |
* rows are retrieved from the database in several chunks (i.e set the |
| 1597 |
* prefetch value smaller than the number of rows). This allows the |
| 1598 |
* database to handle other users' statements while the PHP script is |
| 1599 |
* processing the current set of rows. |
| 1600 |
* |
| 1601 |
* Query prefetching was introduced in Oracle 8i. REF CURSOR |
| 1602 |
* prefetching was introduced in Oracle 11gR2 and occurs when PHP is |
| 1603 |
* linked with Oracle 11gR2 (or later) Client libraries. |
| 1604 |
* Nested cursor prefetching was |
| 1605 |
* introduced in Oracle 11gR2 and requires both the Oracle Client |
| 1606 |
* libraries and the database to be version 11gR2 or greater. |
| 1607 |
* |
| 1608 |
* Prefetching is not supported when queries contain LONG or LOB |
| 1609 |
* columns. The prefetch value is ignored and single-row fetches will |
| 1610 |
* be used in all the situations when prefetching is not supported. |
| 1611 |
* |
| 1612 |
* When using Oracle Database 12c, the prefetch |
| 1613 |
* value set by PHP can be overridden by Oracle's |
| 1614 |
* client oraaccess.xml configuration file. Refer |
| 1615 |
* to Oracle documentation for more detail. |
| 1616 |
* |
| 1617 |
* @param resource $statement A valid OCI8 statement |
| 1618 |
* identifier created by oci_parse and executed |
| 1619 |
* by oci_execute, or a REF |
| 1620 |
* CURSOR statement identifier. |
| 1621 |
* @param int $rows The number of rows to be prefetched, >= 0 |
| 1622 |
* @throws Oci8Exception |
| 1623 |
* |
| 1624 |
*/ |
| 1625 |
function oci_set_prefetch($statement, int $rows): void |
| 1626 |
{ |
| 1627 |
error_clear_last(); |
| 1628 |
$result = \oci_set_prefetch($statement, $rows); |
| 1629 |
if ($result === false) { |
| 1630 |
throw Oci8Exception::createFromPhpError(); |
| 1631 |
} |
| 1632 |
} |
| 1633 |
|
| 1634 |
|
| 1635 |
/** |
| 1636 |
* Returns a keyword identifying the type of the |
| 1637 |
* OCI8 statement. |
| 1638 |
* |
| 1639 |
* @param resource $statement A valid OCI8 statement identifier from oci_parse. |
| 1640 |
* @return string Returns the type of statement as one of the |
| 1641 |
* following strings. |
| 1642 |
* |
| 1643 |
* Statement type |
| 1644 |
* |
| 1645 |
* |
| 1646 |
* |
| 1647 |
* Return String |
| 1648 |
* Notes |
| 1649 |
* |
| 1650 |
* |
| 1651 |
* |
| 1652 |
* |
| 1653 |
* ALTER |
| 1654 |
* |
| 1655 |
* |
| 1656 |
* |
| 1657 |
* BEGIN |
| 1658 |
* |
| 1659 |
* |
| 1660 |
* |
| 1661 |
* CALL |
| 1662 |
* Introduced in PHP 5.2.1 (PECL OCI8 1.2.3) |
| 1663 |
* |
| 1664 |
* |
| 1665 |
* CREATE |
| 1666 |
* |
| 1667 |
* |
| 1668 |
* |
| 1669 |
* DECLARE |
| 1670 |
* |
| 1671 |
* |
| 1672 |
* |
| 1673 |
* DELETE |
| 1674 |
* |
| 1675 |
* |
| 1676 |
* |
| 1677 |
* DROP |
| 1678 |
* |
| 1679 |
* |
| 1680 |
* |
| 1681 |
* INSERT |
| 1682 |
* |
| 1683 |
* |
| 1684 |
* |
| 1685 |
* SELECT |
| 1686 |
* |
| 1687 |
* |
| 1688 |
* |
| 1689 |
* UPDATE |
| 1690 |
* |
| 1691 |
* |
| 1692 |
* |
| 1693 |
* UNKNOW. |
| 1694 |
* @throws Oci8Exception |
| 1695 |
* |
| 1696 |
*/ |
| 1697 |
function oci_statement_type($statement): string |
| 1698 |
{ |
| 1699 |
error_clear_last(); |
| 1700 |
$result = \oci_statement_type($statement); |
| 1701 |
if ($result === false) { |
| 1702 |
throw Oci8Exception::createFromPhpError(); |
| 1703 |
} |
| 1704 |
return $result; |
| 1705 |
} |
| 1706 |
|
| 1707 |
|
| 1708 |
/** |
| 1709 |
* Unregister the user-defined callback function registered to connection |
| 1710 |
* by oci_register_taf_callback. See |
| 1711 |
* OCI8 Transparent Application Failover (TAF) Support |
| 1712 |
* for information. |
| 1713 |
* |
| 1714 |
* @param resource $connection An Oracle connection identifier. |
| 1715 |
* @throws Oci8Exception |
| 1716 |
* |
| 1717 |
*/ |
| 1718 |
function oci_unregister_taf_callback($connection): void |
| 1719 |
{ |
| 1720 |
error_clear_last(); |
| 1721 |
$result = \oci_unregister_taf_callback($connection); |
| 1722 |
if ($result === false) { |
| 1723 |
throw Oci8Exception::createFromPhpError(); |
| 1724 |
} |
| 1725 |
} |
| 1726 |
|