Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to handle Facebooks new UID sizes?

I've been working a little bit on a Facebook application, but when I registered a new user to test the friend interaction the new user got a uid (100000XXXXXXXXX) that seems to big for php to handle.

Saving the number in the database results in the same value (2147483647). I'm guessing this is also PHPs fault, as I would believe the uid would fit in an unsigned bigint?

I'm not quite sure where to go from here, any suggestions?

like image 585
Marco Avatar asked Dec 05 '22 04:12

Marco


2 Answers

The fix is to store the UID as a string always. Use the VARCHAR field type in MySQL and you will be fine.

In general, many database gurus will tell you that interpreting another application's foreign keys (like UID in this case) is bad bad bad and you should handle them as opaque text.

like image 135
intgr Avatar answered Dec 08 '22 06:12

intgr


Facebook recommonds to store it as a BIGINT unsigned.

User object details and connections can be found here.

For PHP, you'd store it as a string (because, ultimately, if you're going to use it, it's going to be displayed on the page or in JSON data or something else that's stringy. There's no real need to perform arithmetic on that number).

like image 34
Shawn Leslie Avatar answered Dec 08 '22 05:12

Shawn Leslie