Sunday, June 10, 2007

php-oracle bogosity #1

That's not #1 as in it's the worst of its kind. I'm very new to playing with oracle on php, and it's only Oracle 10g Express Edition, so I am definitely not saying anything about oracle in general.

This might even be just a php-oracle thing, not necessarily in the oracle API at all (i tried to read that, got bored and came to no conclusion). In any case, I wasted a few days on this. I'm on vacation and getting online to fix something involves going to the internet cafe in the city. I only do that once a day. Of course, reading the documentation of oci_fetch_array would have helped :-), but I didn't realize oci_fetch_array could be this bogus.

In PHP, oci_fetch_array takes as parameters a resource statement (result of oci_parse) and some integer parameters. Apparently, Oracle (or the PHP-OCI8 library anyway) by default will not return null columns. It's necessary to specify OCI_RETURN_NULLS if you want null columns in the returned row. This is just bogus though. What does it cost to return some extra array entries, after all. Particularly if they're null or empty (which is a separate pure-oracle bogosity for later). It certainly creates an unnecessary asymmetry to have rows sometimes be 10 columns and sometimes 12 depending on whether certain columns in the returned row are null.

No comments: