Multiple OCI8 and PHP versions in parallel

You can easily switch between multiple versions of PHP with: But if you installed the Oracle oci8 extension, you will probably run into the error, that it can not be loaded when switching to the older php version: Unable to load dynamic library ‘oci8.so’ This happens, because pecl uninstalls the previous oci8 version automatically unless …

Quick Tip: Access Oracle LOB directly from PHP

Access the data from a clob/blob field without having to call OCI-Lob->load() first When you fetch (binary) data from an Oracle database field of type BLOB or CLOB with OCI8, the (binary) large object is normally returned as LOB descriptor (an instance of the OCI-Lob class). To retrieve the data, you have to call the …

PHP Tip: Binding variables in a SQL WHERE IN clause

Have you ever wondered if it is possible to bind an unknown amount of variables in a SQL WHERE IN clause, e.g.: SELECT id, text FROM myTable WHERE id IN (:myId1, :myId2, myId3, …) Use a OCI collection object and wonder no more: $keyList = array(100, 250, 350); $stmt = oci_parse($cnn, “SELECT id, text FROM …

SQL tip: How to bind NULL with PHP and Oracle

Neat little trick to bind a null value without using an if clause. How often have you done something like this when a variable might be null: $sql = “SELECT * FROM someTable WHERE col1 = :firstVar”; if ($secondVar !== null) { $sql.= ” AND col2 = :secondVar”; } … oci_bind_by_name($stmt, ‘:firstVar’, $firstVar); if ($secondVar …