Experience with Oracle

Hi,

I am new to the forum and Yii.

We have a web app and planning to migrate it to a new environment.

Yii seems to be pretty cool but we have some concerns.

The first one is how it works with Oracle.

Some tests we made failed and we have to modify some oci files to make it work.

So the question: Is someone over there working with Yii and Oracle on a production environment?

I would like to share some experience before moving forward.

Thanks,

Juan Martín.

Hi,

I was working on bigger project using PHP (Yii) and Oracle database (through PDO and Yii).

You might read some of my thoughts on PHP+Oracle in these articles:

Using Yii with Oracle through PDO

Increasing AR performance in connections with Oracle

and these my forum posts:

CGridView (through PDO) is not able to fetch simple data set from Oracle DB

Oracle column names case-sensitivity

Forcing database charset when connecting to Oracle

If, for some reasons (as I do) you can’t use good caching component and/or you’re be dealing with a large data sets (hundreds of thousands of records), then Acrtive Record performance using Oracle is rather poor, in comparison to other RDBMS. Though other might not agree, this is my feeling after around years of using Yii and Oracle.

I would not suggested using Oracle with PHP, unless you have additional time and money to spend on fighting with sometimes idiotic problems and errors. Notice, that this is not Yii problem, but PHP itself. Simply, take into consideration that Oracle driver for PHP is like five or even more years still in experimental phase:

Oracle Functions (PDO_OCI)

and even it’s own developers claims that using it in any production application is highly not recommended and that you’re actually using it at your own risk!

In general, may have a lot of additional troubles, if you’re developing application that uses different encoding than data encoding in your Oracle database. I was forced to do so, building UTfF-8 application upon old Latin-1 encoded database. Horrible problems (exceptions on data columns exceeding their defined length) and all because of a stupid bug, reported like a five years ago and not fixed until now, even though fixing it requires to change one line in pdo_oci.dll and recompile of that library:

https://bugs.php.net/bug.php?id=54379

If I’m not mistaken, ricardograna (generic profile) is a very talented Oracle and PHP developer. Look for his posts and wiki articles.

My general opinion: I’ve learnt a lot and was very good paid for the project I done, but I would think twice or even three times before getting myself into another PHP+Oracle combo project.

Trejder,

Thanks for sharing your experience.

What I would say about Oracle+PHP is that they work really nice together and that combination is "enterprise ready".

That is with the Oracle OCI8 driver for PHP (I mean not PDO)

In fact it is supported and the version 11g of the database has a new connection pooling mechanism for PHP.

See OTN on Oracle (I am not allowed to post links) for details.

We have an application working with PHP and Oracle without problems.

We want to make the PHP side more "elegant" and that is why we are evaluating Yii.

What I don’t know is about the PDO_OCI driver which is popular in the frameworks world.

I will continue researching on this.

Thanks again for your reply,

JMG.

So this is the deal with Yii and Oracle.

The short version of the story is: if you want to be serious about using Oracle with PHP you should not use PDO at all.

PDO seems to be a dead end on the Oracle side and is not the most active project over there anyway.

The "Experimental" status of the PDO driver for Oracle is enough to avoid using it.

And this is even more important if you need (like us) to use some features not available on PDO at all, like functions/procedures, LOBs, ref cursors, etc.

Quoting from the PDO site: "This extension is EXPERIMENTAL. (…) This extension should be used at your own risk."

Quoting from the book "The Underground PHP and Oracle Manual": "The PHP community has let the PDO project languish and Oracle recommends using OCI8 instead whenever possible because of its better feature set, performance and reliability."

It seems there is no deal here.

Does any of you know if version 2.0 is still using PDO?

Thanks,

JMG.

I think that you mixed up two things.

PDO isn’t bad just because it has so incredibly bad OCI driver. I personally think that it is perfect and would be very disappointed if Yii2 would drop support on it. Yes, I agree that it has many errors, it hasn’t been updated for a long, long time and is missing many important features of Oracle, but I wouldn’t mix these facts with whole PDO. To be honest, I admire PDO that much, that if I would have to write a bigger project using PHP and Oracle I would consider hiring a C++ developer to write my own version of OCI driver for it.

Yes, I’ve heard that Oracle works fine with OCI8, is much more stable and provide more functions. But, as you pointed out correctly, it does not support PDO and therfore is not used in many famous frameworks that are build over PDO and are using it to get hands on all database stuff.

You can’t (or at least shouldn’t be) surprised of this situation. We may think different, but in general PHP is not recognised as good addition to Oracle. Simple because most people take Oracle as mature (maybe even most mature) RDBMS system while the same amount of people treats PHP like a toy for writing simple websites, not a professional coding language. Leaving Facebook (written almost entirely in PHP, and many more mature web apps) ahead, we must admit that an unbelievable mess in PHP and a very poor support for Oracle through PDO are the facts that supports this kind of thinking.

Trejder,

Thank you for sharing your thoughts.

First I think we don’t think as different as you think :)

If I need to express my opinion in one sentence I would quote my last message: "if you want to be serious about using Oracle with PHP you should not use PDO".

I am not happy with that but this is the way it is.

If I can convince the right person on my company to use it (as I might be) I won’t use PDO with Oracle anyway.

From our side the database is the most important piece of software on the application.

The application logic is on PL/SQL and we use advanced features from the database.

That is why there is no deal with PDO for us.

Believe me, I am not blaming PDO.

I am just pointing that it is not an option for Oracle at the current development stage.

I agree with you about the kind of thinking that PHP is not an enterprise class coding language.

And that the combination with Oracle is poor.

I cannot disagree more with both statements.

PHP is a professional development language for sure. It is not the language but what you do with it from my point of view.

And PHP and Oracle IS a perfectly good combination if you use OCI8 driver.

There is people from Oracle working actively on the development of that driver and works perfectly.

The bottom line is that in a perfect world you can use PDO to get the best of Oracle.

Is does not seem to be the case.

Thanks again for sharing,

JMG.

Well… I must agree with you on mostly everything! :] But let me change the topic a little bit, OK?

Your statement that Oracle DB is most important part of your application and that you have all application logic in PL/SQL leads me to a bit different conclusion. Do you really need Yii? :]

The guy, I was working with on the project were we used Oracle na PHP (he was responsible for PL/SQL code, I – for PHP, Yii, client-side and such stuff) told me, that with the power that can be unleashed using PL/SQL Yii becomes actually a view-only layer for the application. And therefore can be minimised or eliminated. He is even thinking seriously on some kind of PL/SQL framework that would generate directly a HTML output sent back to browser and some .NET mini-server that would pass requests to that PL/SQL framework. This way, actually everything would be done in PL/SQL. And not only Yii, but anything else between client browser and Oracle DB could be dropped.

I personally disagree and would prefer to stay with Yii! :]

But looking at a things like Kendo UI makes me a little bit suspicious, where web-development is going. Have you heard about that framework? Build over jQuery with many additions to it (and many, many new widgets) with full support for HTML5 and CSS3 and full mobile support out-of-the-box. Here are some examples:

http://www.kendoui.com/

http://demos.kendoui…view/index.html

http://demos.kendoui…operations.html

http://demos.kendoui.com/aeroviewr/

The general rule says that all you need to do, is to provide data in JSON format (which is easy as a glitch in any web-language). Everything else (or mostly everything else) that is need by an web application (like presenting in grids, editing, visualising on diagrams) is done on client-side with Kendo UI. Look at the example.

About your question "Do you really need Yii?"…

Well, there are just a few things people actually "need".

For all other things is a matter of "want" or "like".

Do we need Yii? Maybe not.

We want to improve the PHP side of the house for sure.

That would mean having a good framework, improving tests, migrating to TDD, etc.

We have several options for that.

The true is that in the technology field there are lots of choices to make.

You can do everything on the database or almost everything on the application side (1), among a lot of other options you have.

The discussion about the pros and cons of each options is too big for this message but you get the point.

The problem is that when we are good with the hammer we tend to think that every problem is a nail.

There is no best solution for any problem.

It depends on the nature of the problem and the people working on it. Mostly on the people.

Finally, where is the web-development going?

Tricky question, isn’t it?

Personally I see a few milestones on the web-development field (of course this is also a huge topic to discuss here).

First Javascript libraries. The are playing a big role on enabling better user experience on the client side.

Firefox as a development tool helped too.

The Javascript framework you mention is related to this. There will be more projects like this, essentially expanding the jQuery-UI project.

One of the biggest changes (not so new but extremely popular now) is AJAX. That changed the way the browser is used as a client agent.

What to do client-side and what to do server-side is (2) a design desition that a developer has to make.

One side (client) will not replace the other (server) (3) or viceversa.

JMG

(1) I consider this a biased term. The database is the application side too! :)

(2) This was always a desition to make, this is not new. But as the client side becomes more complex, more is handled by the user agent than before.

(3) Who will create that JSON data for the client anyway? :)

Thanks again for detailed explanation! :]

I’ve never hear this, but I must admit that this will be from now on one of my best texts, as this is so painfully true! :]

You, of course. I was saying, that with this approach (forcing more and more on client side) you don’t need to higher a big framework as you can craft a few lines of code that will change SQL result into JSON code.

But that was only an example and I agree with you that using a framework (Yii or another) does brings a lot of help in coding small or big projects.

Hi,

There are some news about oracle and yii?

I have an Oracle 11.2 server (with big tables ) and yii 11.2 (PDO connection)result is that appliction not usable absolutely too slow.

I read many of the posts and I experimented all the problems reported I’m thinking about dropping the development with Yii, before this someone have a check list of the action to take to make an yii project usable ?

I’ve been using Oracle with my Yii application over 5 years.

I have a high-demand application that manages around 50000 subsscripts per month.

Yes, we do have some problems with PDO-OCI. They are not too many and they only happen in specific cases.

I highly suggest you these approaches:

1 - Make good use of CACHE (APC, in special. If using Windows, use CFileCache)

2 - For databases with many schemas:

2.1 - For development, make a virtual machine with an Oracle Instance. Inside it, make a new databse with only the schema you need. Your performance will improve like hell.

2.2 For production, remember the item #1: CACHE. Yes, application will go slow for the first time loading tables, but the subsequent calls will go fast.