zendframework/zend-db

It could not be fetched bound variable if use Oci8 driver

Opened this issue · 8 comments

Oci8 driver does not support some functionality of original oci8 driver. See official doc:

In Oracle, bind variables are commonly divided into IN binds for values that are passed into the database, and OUT binds for values that are returned to PHP. A bind variable may be both IN and OUT. Whether a bind variable will be used for input or output is determined at run-time.

This means that if I want to make OUT bind variable, it value could not be fetched. For example, I want to execute such query
BEGIN :xml := xml_builder.get_mega_simple_xml(:p_param);END;
In this example two variables: one IN - :p_param, and one OUT - :xml. The value of :xml param could not be fetched via Zend-db driver.

@Ocramius, I don't think so. See my pull-request which fix this issue

Yes, that's still exposing everything by-ref, and that is indeed a mess.

I think in another way. Mess it is when some abstractions doesn't provide native functionality.

@Ocramius, I still don't understand you.
zend-db already use by-ref modification of parameter just because it use oci_bind_by_name function. It already can lead to unexpected by-ref modification of Zend\Db\Adapter\Driver\Oci8\Statement class. And question is why zend-db don't provide native oci8 functionality while it has oci8 abstraction layer and it is possible to add such functionality in current architectural model.
Also zend-db is a great component, and I simply use overrided Statement and ParameterContainer classes in production projects.

zend-db already use by-ref modification of parameter just because it use oci_bind_by_name function.

Yes, that is normal, since the OCI8 layer only works with references. Indeed, it should be changed so that the value is de-referenced before being passed on to the oci_bind_by_name call. Need to find a way to do that without triggering GC.

And question is why zend-db don't provide native oci8 functionality while it has oci8 abstraction layer and it is possible to add such functionality in current architectural model.

A ParameterContainer is not an OCI8 abstraction, it's an abstraction around parameters for any DB adapter inside zend-db.

If the native functionality does not exist in other drivers, it cannot be abstracted away and made common, since all other adapters won't support it. That's why I initially said that you should just use the underlying oci8 layer.

The same rules apply to basically most database abstraction layers: in Doctrine, for example, we only ever support features that are common to all platforms, nothing more.

It already can lead to unexpected by-ref modification of Zend\Db\Adapter\Driver\Oci8\Statement class.

If that's happening, that is a quite bad bug, and should be fixed as per first comment above.

This repository has been closed and moved to laminas/laminas-db; a new issue has been opened at laminas/laminas-db#76.