oci_new_collection
(PHP 5, PECL OCI8 >= 1.1.0)
oci_new_collection — Allocates new collection object
Description
$connection
, string $tdo
[, string $schema
= NULL
] )Allocates a new collection object.
Parameters
-
connection
-
An Oracle connection identifier, returned by oci_connect() or oci_pconnect().
-
tdo
-
Should be a valid named type (uppercase).
-
schema
-
Should point to the scheme, where the named type was created. The name of the current user is the default value.
Return Values
Returns a new OCICollection object or FALSE
on
error.
Notes
Note:
In PHP versions before 5.0.0 you must use ocinewcollection() instead. This name still can be used, it was left as alias of oci_new_collection() for downwards compatability. This, however, is deprecated and not recommended.
- PHP Руководство
- Функции по категориям
- Индекс функций
- Справочник функций
- Расширения для работы с базами данных
- Расширения для работы с базами данных отдельных производителей
- Oracle OCI8
- oci_bind_array_by_name
- oci_bind_by_name
- oci_cancel
- oci_client_version
- oci_close
- oci_commit
- oci_connect
- oci_define_by_name
- oci_error
- oci_execute
- oci_fetch_all
- oci_fetch_array
- oci_fetch_assoc
- oci_fetch_object
- oci_fetch_row
- oci_fetch
- oci_field_is_null
- oci_field_name
- oci_field_precision
- oci_field_scale
- oci_field_size
- oci_field_type_raw
- oci_field_type
- oci_free_descriptor
- oci_free_statement
- oci_get_implicit_resultset
- oci_internal_debug
- oci_lob_copy
- oci_lob_is_equal
- oci_new_collection
- oci_new_connect
- oci_new_cursor
- oci_new_descriptor
- oci_num_fields
- oci_num_rows
- oci_parse
- oci_password_change
- oci_pconnect
- oci_result
- oci_rollback
- oci_server_version
- oci_set_action
- oci_set_client_identifier
- oci_set_client_info
- oci_set_edition
- oci_set_module_name
- oci_set_prefetch
- oci_statement_type
Коментарии
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#l429