On Mon, February 27, 2012 5:21 pm, Ángel González wrote:
> On 27/02/12 19:22, Richard Lynch wrote:
>>>> I'm not so sure about that. In a well-written web application, you
>>>> would
>>>> typically convert them on the first layer, when receiving from the
>>>> web.
>>>> On next usages, your int variables are usually ints already.
>> Afraid not.
>>
>> It turns out that PHP, on 32-bit hardware, converting large BIGINT
>> using (int) $ID ends up as a negative number, and then when you pass
>> it in to the database if a string query, you get a negative ID, not
>> at
>> all what was intended.
>>
>> (Been there, done that, got burned)
>>
>> At least, that's been my experience with some versions of PHP and
>> some
>> database drivers.
>>
>> So at least the database IDs have to remain as strings, if you are
>> using BIGINT.
>>
>> You could, of course, only convert the values known to be in range
>> of
>> PHPs positive integers, and leave the others as strings.
>>
>> This is just a simple example of how the super strict typing simply
>> doesn't work out too well in PHP.
> That's a good example from experience.
> Although if you want to keep ids as strings, you can simply keep them
> as a
> string type.
> I was thinking on input coming from a web browser, btw.

In a pagination of billions of items, it could come from the browser...

Of course, you'd need something like a relativistic paginator such as:

First | -1,000,000 | -100,000 | -10,000 | -1,000 | -100 | -10 |
current | +10 | +100 | +1,000 | +10,000 | +100,000 | + 1,000,000 |
Last

Of course, you need to show 10 per page for this to be navigable to
any item.

I had to write such a beast once, though the range was only in the
100K, not billions...

And it took some user-training, but it was an internal tool, so that
was okay.

Even the CEO who didn't know how to work email (literally) managed to
figure it out eventually.

You can get to billions with only 6 more links, however. :-)

-- 
brain cancer update:
http://richardlynch.blogspot.com/search/label/brain%20tumor
Donate:
https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=FS9NLTNEEKWBE



-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to