This is a woefully underdocumented feature (at least here), but being able to bind collections to prepared statements instead of rolling your own SQL arrays is a massive improvement in terms of safety and conveinience, and a feature I think more DBMS should have in their API.
You can basically send collections of the types listed by the following query :
SELECT * FROM SYS.ALL_TYPES WHERE TYPECODE = 'COLLECTION' AND TYPE_NAME LIKE 'ODCI%'
Those are all collections that can contain any number of the SQL type indicated in their name.
<?php
$my_array = ["foo", "bar", "baz"];
$my_collection = oci_new_collection($conn, 'ODCIVARCHAR2LIST', 'SYS');
foreach($my_array as $elem) {
$cell_collection->append($elem);
}
oci_bind_by_name($statement, ":collection", $my_collection, -1, SQLT_NTY);
?>
The collection ressource can be appended with numbers, strings or dates (which need to be passed as strings in the "DD-MON-YY" format, such as "27-MAR-18", apparently) depending on the types supported by the collection you're using, and none of these appear to support timestamps or any of the more complex data types.
Code for the OCI collection type, for reference :
http://git.php.net/?p=php-src.git;a=blob;f=ext/oci8/oci8_collection.c;hb=refs/heads/master#l429oci_new_collection
Почист и полокален преглед на PHP референцата, со задржана структура од PHP.net и подобра читливост за примери, секции и белешки.
oci_new_collection
Референца за `function.oci-new-collection.php` со подобрена типографија и навигација.
oci_new_collection
Класата OCICollection
oci_new_collection — Алоцира нов објект за колекција
= NULL
$connection, string $type_name, ?string $schema = null): OCICollection|falseАлоцира нов објект за колекција.
Параметри
connection-
или со поставување на променливата на oci_connect() or oci_pconnect().
type_name-
Треба да биде валиден именуван тип (со големи букви).
schema-
Треба да укажува на шемата каде што е креиран именуваниот тип. Името на тековниот корисник се користи кога
nullсе предава.
Вратени вредности
параметарот специфицира само излезна кодировка. Ако се помине празен стринг, парсерот се обидува да идентификува во која кодировка е документот кодиран со гледање на првите 3 или 4 бајти. Стандардната излезна кодировка е UTF-8. Поддржаните кодировки се OCICollection објект или false при грешка.
Дневник на промени
| Верзија | = NULL |
|---|---|
| во тековната позиција на големиот објект. |
schema сега е null.
|
Белешки
Забелешка:
На OCICollection класата беше повикана OCI-Collection пред PHP 8 и OCI8 3.0.0.