QuickForm entry problem with BIGINT

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

QuickForm entry problem with BIGINT

Postby ADobkin » Mon Oct 29, 2007 9:39 am

I have a few fields that are defined as BIGINT unsigned in MySQL. When I enter data into these fields in Dataface, they are truncated to INT (only 10 digits, up to around 4 million). Is there something I have to specify in fields.ini or elsewhere to tell Dataface / QuickForm that these are bigger than regular integer fields?

Thanks,
Alan
ADobkin
 
Posts: 195
Joined: Mon Oct 22, 2007 7:31 pm
Location: Atlanta, GA, USA

Postby shannah » Mon Oct 29, 2007 10:10 am

Hi Alan,

This is a bit of a sticking point right now... Unfortunately Dataface treats BigInt fields as an integer also, which is subject to PHP's limitations on integer size.

I suppose a workaround might be to treat the field as a varchar field, so that Dataface doesn't try to work with it as an integer.

You can try
Code: Select all
[fieldname]
    Type="varchar(32)"


in the fields.ini file... i'm not sure if this will be enough to prevent PHP from treating the value like an integer...

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

Postby ADobkin » Mon Oct 29, 2007 10:47 am

Yes, that seems to work! Thanks for the tip and the quick response.

Out of curiosity, I looked up the PHP man page for this:
http://us.php.net/int

According to this section, it looks like Dataface may be able to just use float instead of int for BIGINT:

Integer overflow

If you specify a number beyond the bounds of the integer type, it will be interpreted as a float instead. Also, if you perform an operation that results in a number beyond the bounds of the integer type, a float will be returned instead.


Would that be a better solution, or is there something I'm missing? (I'm no expert on PHP.)

Thanks,
Alan
ADobkin
 
Posts: 195
Joined: Mon Oct 22, 2007 7:31 pm
Location: Atlanta, GA, USA

Postby shannah » Mon Oct 29, 2007 11:00 am

The float suggestion is something to look into, but it would probably require some modifications in the dataface core to adapt to the float representations of the numbers.

That said, a float may run into problems with precision, because all it will be doing is changing the representation from say:

990000 to 99E4

But for more intricate numbers like 9912345... etc.. this simple transformation may still run into problems with storage size and precision.

For now probably the safest way is to just treat them as varchars... Then you can do your own conversions in your triggers when you need to deal with them as integers.

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

Postby ADobkin » Mon Oct 29, 2007 11:09 am

Okay, thanks. Mainly, I am using BIGINT right now to store caller ID (10 digits, no formatting, but slightly larger than the 4M limit on INT) and a few other values. Precision is important in this case, since the number has to be exactly the same up to the last digit. Would it be better to store these as VARCHAR instead? I just thought that BIGINT would be faster and use less space and memory, plus it enforces it as a numeric field.
ADobkin
 
Posts: 195
Joined: Mon Oct 22, 2007 7:31 pm
Location: Atlanta, GA, USA

Postby shannah » Mon Oct 29, 2007 11:28 am

If I were you I'd stick with BigInt. I use INT(11) for most of my ID fields also, i guess the values in them haven't topped to max PHP int value yet.

I will have to revisit the way dataface handles integers so that it deals with this situation better, but in the mean time tricking dataface into thinking they are varchar fields is probably the best bet.

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


Return to Xataface Users

Who is online

Users browsing this forum: No registered users and 31 guests

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