mstap42 Posted January 31, 2006 Share Posted January 31, 2006 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! Quote Link to comment https://forums.phpfreaks.com/topic/3294-solution-sending-oracle-null-to-excel/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.