Jump to content

Oracle NULL and PHP


mstap42

Recommended Posts

I've run into a bit of a snag with querying Oracle in PHP and wondered if you had any ideas. The problem is null values. With my scripts, when data is sent to HTML tables or Excel, the nulls aren't recognized, and the value to the right is moved into that blank position. Otherwise, where all fields have some content, the data is displayed correctly.

Example:

SELECT last_name, first_name, middle_initial, profile
FROM mydb.operators

If middle_initial contains nothing, the profile value is written in the middle_initial column:
last_name first_name middle_initial profile
Simpson Homer admin

I would like to be able to substitute a blank value with something like a tab (\t). But tests with PHP's is_null() and empty() functions seem to show that these functions do not recognize the Oracle null at all. With error_reporting set to 2047 (E_ALL), they return nothing--neither Null nor Not Null, neither Empty nor Not Empty. Whether a field is populated or not, isset() shows the value to be Set.

So conditional statements like this fail:
[!--fonto:Courier New--][span style=\"font-family:Courier New\"][!--/fonto--]
if ((!isset($value)) || ($value == "")) {
$value = "\t";
}[!--fontc--][/span][!--/fontc--]

The conditions [!--fonto:Courier New--][span style=\"font-family:Courier New\"][!--/fonto--]is_null($value)[!--fontc--][/span][!--/fontc--] and [!--fonto:Courier New--][span style=\"font-family:Courier New\"][!--/fonto--]empty($value)[!--fontc--][/span][!--/fontc--] also fail.

Is there something about Oracle null values that PHP can't see? Is there some other function I could use to identify Oracle nulls for character substitution?

Many thanks!
Link to comment
Share on other sites

  • 10 months later...
  • 2 months later...
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.