Can I use Yii if I do not have a PDO extension available?

We use Oracle as our database and would like to use Yii. The problem is that the PDO_OCI extension is marked as "experimental" and our system administrators cannot install it as a result. If we want to use Yii it seems we will need to stick with OCI8 by itself. Additionally, we make heavy use of PL/SQL and PDO_OCI does not have all the support for this that OCI8 does.

Is using OCI8 viable or do we miss out on too many features by not having PDO available? It looks like we lose the ability to do scaffolding and I am not entirely sure at first glance how much work we’ll have to do to replace CDbConnection with a non-PDO version. Has anybody used Yii extensively with OCI8 or is most everybody using Yii with PDO_OCI or a different database altogether?

I do not have a complete understanding of Yii’s architecture so I do not know how serious of a problem our limitation is. Can somebody steer me in the right direction or describe how they have managed this issue?

You can take inspiration from this.

I tested successfully with mysql database, but no idea about how it will work with Oracle.

Let us know if you solved!

zacarria: That project does look interesting but I’m not sure if we’re up to the task of integrating it with Yii and testing it completely. I will look into it more closely when I have a chance. Even if we did manage to hack in a some kind of pseudo-PDO support we’d still have to use OCI8 in many cases. All our inserts/updates/deletes are performed through stored procedures, and PDO does not support PL/SQL.

I wrote a CApplicationComponent extension using OCI8 to replace the default CDbConnection component. So far it seems like we lose CActiveRecord if we don’t have PDO. My thought is that we then have to use CFormModel for persisted forms (in place of CActiveRecord) and then manually write the insert statements to save form data.

The more I look into it, the more of an issue it looks like this is going to be for us. As an example, CGridView by default relies upon an ActiveRecord implementation of IDataProvider. I’m just worried that at every step we will have to write custom interface implementations to deal with not having AR.

The basic answer to your question is "Yes, you can most certainly still use Yii as an application development framework without PDO".

It is true that you will not be able to take advantage of some of Yii’s database related features. And, no doubt, Yii’s implementation of Relational AR as an ORM layer is a great feature. However, there are many, many, many reasons to use Yii beyond just Yii DAO.

Thanks for the input zaccaria and jefftulsa.

As I mentioned, I created a custom CApplicationComponent for this and use it in place of the default CDbConnection. I was able to write a small application against our databases using OCI8 directly. It was quick and easy, especially compared to our experiences with Zend_Form. I wish we had AR available but I think we can make do without – I was just concerned that its unavailability may have had more serious consequences, but what I’m seeing so far suggests that the framework components are fairly loosely coupled so it should not be a huge stumbling block.

I am new at Yii and I know this is an older thread, but I am in the same boat as uiowa-dev – can not use PDO-OCI. I am having some difficulties connecting, though and could use some help on getting Yii running with my oci8 driver. I am able to connect with a basic PHP oci_connect statement:


$c = oci_connect("username", "password", "//host:1521/$db_instance");

and I have experimented with the Zend Framework enough to be able to connect to multiple dbs by adding to my application.ini:




[db1 : production ]

resources.db.adapter = "Oracle"

resources.db.params.dbname = "//host1:1521/db_instance1"

resources.db.params.username = "user1"

resources.db.params.password = "password1"


[db2 : production]

resources.db.adapter = "Oracle"

resources.db.params.dbname = "//host2:1521/db_instance2"

resources.db.params.username = "user2"

resources.db.params.password = "password2"



But I can not get a connection in Yii. Maybe that is because all of the specific examples I have found are pdo-oci, not the oci8 drivers. Should I just write oci_connect code into my Model and be done with it?

uiowa-dev said:

What might that look like?

Please advise-

Tim

Ubuntu 10.04

Apache2

PHP5

Oracle 10 & XE