I have philosophical questions about why this would be useful, but why not.

Assuming k and v are a key-value pair of unsigned integers:

update wacky_table set key_val = k << 32 | v;

To get the values back out, I'd recommend just letting the database handle it, 
otherwise you'd have to mess with PHP math extensions (why bother).

select key_val >> 32 as k, key_val & 0xffffffff as v from wacky_table;

J



On Dec 18, 2012, at 7:36 PM, Aaron Luman wrote:

> Hey all, this is probably a really simple problem but I can't seem to figure 
> it out or find a good answer online.
> 
> I am using sphinxsearch and need to create an index based on two 32-bit 
> number key-value pairs.  To do this, I need to join the two into one 64 bit 
> number (in mysql).  I know that there's a way to shift the bits, or 
> something, but I can't quite figure out how to do that.
> 
> Then, in php, i need to break up that 64-bit int into two 32s so that I can 
> use the key-value pair info.
> 
> Thanks for the help
> 
> Aaron
> 
> _______________________________________________
> 
> UPHPU mailing list
> [email protected]
> http://uphpu.org/mailman/listinfo/uphpu
> IRC: #uphpu on irc.freenode.net


_______________________________________________

UPHPU mailing list
[email protected]
http://uphpu.org/mailman/listinfo/uphpu
IRC: #uphpu on irc.freenode.net

Reply via email to