The php Function oci_bind_by_name
The majority of modern web sites rely upon databases in some way. Whether it is to store articles, provide e-commerce functionality or take feedback from visitors, most sites incorporate database access. These queries are normally executed by means of a bind call that takes a statement handle, placeholder and a variable and bundles them together for the database to understand. This article explores one of the important php functions called oci_bind_by_name.
oci_bind_by_name()
The function takes the Oracle connection identifier (as returned by oci_connect() or oci_pconnect()) as its argument and returns an LOB locator or FILE descriptor on success. You may have to allocate a descriptor using the oci_new_descriptor() function before calling this function if you are working with abstract data types (LOB, ROWID, BFILE) or the oci_cursor() function for cursors.
If you use this function with IN binds I recommend that you pass a length parameter to it as well, otherwise Oracle might truncate the bound data to the initial PHP variable value when the oci_execute() is called. This will also prevent oci_bind_by_name() from accidentally resetting the LOB’s internal pointer when you subsequently read the data with other functions such as oci_fetch_array().
Note that if you use this function with CHAR columns, remember to remove any magic_quotes_gpc or addslashes() that are applied to your PHP variables because Oracle uses blank-padded comparison semantics for these columns in WHERE clauses. This can cause your queries to fail if the strings are not blank padded.