mysqli mysqli_stmt::bind_param using bigint
am 08.10.2009 17:09:23 von Philipp Moeser
Hi all,
we used the bind_param function to insert a lot of integers into our
database. As I just found out now quite a few of them were bigints, and
did not end up correctly in the database, because the integer parameter
supports only integers up to 2^32.
Now my question: Anybody know how I can calculate the ID that I have in
my database out of the original ID that was supposed to go there?
Two examples:
original ID: 100000358490906
result in DB: 634938138
original ID: 100000005353484
result in DB: 281800716
I suppose I cannot get the original ID from what i have in the DB, but
how does mysqli calculate that shorter value it passes to DB?
Thanks for any help
Philipp
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: mysqli mysqli_stmt::bind_param using bigint
am 09.10.2009 09:45:24 von maarten.foque
That's quite easy:
100000358490906 gives a 8 byte long hexadecimal value of:
5AF325D8631A
Since integer is 4 bytes long, only the last 4 bytes are probably stored
(or maybe the first 4, that could depend on the code, or your
endianness, but I don't know that).
Anywhay, 25D8631A gives a nice value of 634938138.
Your second is hex 5AF310CBF00C, last 4 bytes 10CBF00C gives =>
281800716
Getting the original value back is not that difficult, just add
100000000000000 hex (5AF300000000)
Now this may just work for you, remember that you can't actually know
what was in those first 4 so adding 5AF300000000 may just be wrong.
However for the examples you gave, it seems to add up.
So you need to have some indication of the range the originals would've
had or the numbers you get are a multiple of 2^32 off.
regards,
Maarten
On Thu, 2009-10-08 at 17:09 +0200, Philipp Moeser wrote:
> Hi all,
>
> we used the bind_param function to insert a lot of integers into our
> database. As I just found out now quite a few of them were bigints, and
> did not end up correctly in the database, because the integer parameter
> supports only integers up to 2^32.
>
> Now my question: Anybody know how I can calculate the ID that I have in
> my database out of the original ID that was supposed to go there?
>
> Two examples:
> original ID: 100000358490906
> result in DB: 634938138
>
> original ID: 100000005353484
> result in DB: 281800716
>
> I suppose I cannot get the original ID from what i have in the DB, but
> how does mysqli calculate that shorter value it passes to DB?
>
> Thanks for any help
> Philipp
>
>
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php