How to get NULL to show up in all views/modes?

A place for users and developers of the Xataface to discuss and receive support.

How to get NULL to show up in all views/modes?

Postby lhat » Mon Sep 14, 2009 9:41 am

Hi, Steve and all--

I'm having a persistent problem in getting an empty MySQL field to show up in Xataface as NULL--we get a blank in all views, or even a space, and my clients really want to see that NULL the way they do in other environments. I also see a NULL when I check the table in phpMyAdmin.

I've checked the docs, but haven't found anything specifically on this--can anyone point me to the right spot?

Many thanks!
lhat
 
Posts: 40
Joined: Thu Aug 06, 2009 3:31 pm

Postby shannah » Thu Sep 17, 2009 9:09 am

This issue is fixed in SVN. Replace Dataface/Serializer.php with the one at http://weblite.ca/svn/dataface/core/tru ... alizer.php
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Alas, values are NULL but views show blanks

Postby lhat » Sat Sep 19, 2009 12:22 pm

Hi, Steve--

Sorry to say, but I've replaced my /htdocs/xataface/Dataface/Serializer.php with the SVN revision, and though the NULLS are staying NULLS in the database fields (as I can confirm by checking with either phpmyadmin or from the mysql command line), when I view those fields in my Xataface app itself in listview, edit, or the like, they show up as blanks rather than as "NULL".

Maybe I need to make some sort of on-the-fly translation (<if>) for this application?
lhat
 
Posts: 40
Joined: Thu Aug 06, 2009 3:31 pm

Postby shannah » Sat Sep 19, 2009 1:00 pm

Yes. Nulls won't say 'Null' in the interface, though they will save as nulls to the database. You can implement the xxx__display() method to show something different in the case of nulls if you like.

e.g.
in your delegate class:

Code: Select all
function xxx_display($record){
    $val = $record->val('xxx');
    if ( !isset($val) ) return 'NULL';
    else return $val;
}
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

xxx_display() not working

Postby lhat » Mon Sep 21, 2009 10:24 am

Hi, Steve.

So, if I'm understanding aright, if I've a table Schools in my db application and in that table a field 'Zip,' for which I want the NULL to display in my lists, edits, finds, and views as "NULL," then in db/tables/Schools I would put a file called Schools.php in which I would put the following delegate class code, adapting from your note:

Code: Select all
<?
<class tables_Schools {
    function Zip_display($record) {
       $val = $record->val('Zip');
       if ( !isset($val) ) return 'NULL';
       else return $val;
    }
}
?>


Alas, this seems to have no effect on the display, so I must be amiss?

I did check the handbook's methods-listing for field__display in the Delegate Class section, and it differs a little from your sample in the initial function label (showing "function %fieldname%__display(&$record)"), but applying those differences also had no effect.

I'm reasonably sure I'm in the right place, since the app breaks w/an error if I have the code significantly wrong--but I'm not sure why the "NULL" isn't appearing.

Thanks...
lhat
 
Posts: 40
Joined: Thu Aug 06, 2009 3:31 pm

Postby shannah » Mon Sep 21, 2009 12:25 pm

A couple of notes:

1. You are right on with your assessment... just a small typo
2. it is Zip__display() not Zip_display()
3. Names of classes, files, and functions are case sensitive and should match the corresponding field or table names.

-Steve
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Got it!

Postby lhat » Mon Sep 21, 2009 2:04 pm

Steve, thanks--

I corrected my typo, but still no luck, so went looking further and found that empty is not NULL; sigh. Setting those records Zip fields to NULL (rather than their being empty) did the trick.

I'll post another question that is, I hope, not quite so lame...[/code]
lhat
 
Posts: 40
Joined: Thu Aug 06, 2009 3:31 pm


Return to Xataface Users

Who is online

Users browsing this forum: No registered users and 27 guests

cron
Powered by Dataface
© 2005-2007 Steve Hannah All rights reserved