Jump to content

Recommended Posts

In case anyone wondered...

Recall the problem: I modified the code from the PHPFreaks tutorial "Exporting MySQL To Excel" to send my Oracle data to Excel, but was unable to substitute "\t" for null values, thus:

[!--fonto:Courier New--][span style=\"font-family:Courier New\"][!--/fonto--]while($row = oci_fetch_row($stmt)) {
$line = '';
foreach($row as $value) {
if ((!isset($value)) OR ($value == "")) {
$value = "\t"; // if $value is blank, write a tab...
} else {
...
}[!--fontc--][/span][!--/fontc--]

Tests with ($value == ""), is_null(), and empty() returned *nothing*. Not TRUE, not FALSE, but exactly nothing. So tabs weren't substituted for NULL values, and therefore data got slammed to the left in the Excel file.

Evidently, (and assuming the tutorial's code works as advertised for NULL values), there's not a one-to-one correspondence between mysql_fetch_row and oci_fetch_row.

But, *this* works against Oracle 9i:

[!--fonto:Courier New--][span style=\"font-family:Courier New\"][!--/fonto--]while($row = oci_fetch_array($stmt, OCI_NUM + OCI_RETURN_NULLS)) {
...
}[!--fontc--][/span][!--/fontc--]

If you think you want to try the tutorial's approach, remember that oci_num_fields follows oci_execute. Sounds pretty basic, but it tripped me up the first time.

Thanks to everyone who took a look at the original post!







Link to comment
https://forums.phpfreaks.com/topic/3294-solution-sending-oracle-null-to-excel/
Share on other sites

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.