Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old April 11th, 2007, 10:45 PM
David T. Ashley
Guest
 
Posts: n/a
Default PHP 4.X and 64-Bit Integers from MySQL

I have a box where I'm forced to use PHP before 64-bit integers became
standard ...

If I run a MySQL query where one of the fields returned is 64-bit integer,
how do I get this into PHP as a string? My recollection is that in the
result sets it "auto types" so that it is an integer, and 64-bit integers
will cause problems if one tries to assign into 32 bits.

P.S.--Once into PHP as a string, I would use the bcmath library to
manipulate it ...
--
David T. Ashley (dta@e3ft.com)
http://www.e3ft.com (Consulting Home Page)
http://www.dtashley.com (Personal Home Page)
http://gpl.e3ft.com (GPL Publications and Projects)


  #2  
Old April 13th, 2007, 12:05 AM
Henk verhoeven
Guest
 
Posts: n/a
Default Re: PHP 4.X and 64-Bit Integers from MySQL

Hi david,

Maybe you could use CONV(`columnname`, 10, 10) in your SQL to convert
the integer to a string before it is passed to php.

for example if the colum holding 64 bits integers is named `theInt`:

SELECT id, CONV(theInt, 10, 10) FROM yourtable

would return the id and theInt columns but theInt converted to a string.

Once the string is in php you may use GMP functions for calculations
etc., see http://nl2.php.net/manual/en/ref.gmp.php

Success,

Henk Verhoeven,
www.phppeanuts.org.

David T. Ashley schreef:
Quote:
I have a box where I'm forced to use PHP before 64-bit integers became
standard ...
>
If I run a MySQL query where one of the fields returned is 64-bit integer,
how do I get this into PHP as a string? My recollection is that in the
result sets it "auto types" so that it is an integer, and 64-bit integers
will cause problems if one tries to assign into 32 bits.
>
P.S.--Once into PHP as a string, I would use the bcmath library to
manipulate it ...
  #3  
Old April 13th, 2007, 02:35 AM
David T. Ashley
Guest
 
Posts: n/a
Default Re: PHP 4.X and 64-Bit Integers from MySQL

Hi Henk,

Thanks for the help. I will look up the CONV() function.

A person on the MySQL mailing list suggested the CONCAT() function for the
same purpose. If that fails, I believe that MySQL has an explicit CAST()
function that should definitely work.

And, if that fails, there would seem to be two other options:

a)Looking for a MySQL operator that will manipulate the integer into
something that can't be parsed as an integer, something like "95" becomes
"S95" or even something like "IE" (9th letter, 5th letter).

b)Storing a field in parallel with the 64-bit integer that is definitely
text and contains the value in a different form.

So, I have a lot to try!

Thanks!
--
David T. Ashley (dta@e3ft.com)
http://www.e3ft.com (Consulting Home Page)
http://www.dtashley.com (Personal Home Page)
http://gpl.e3ft.com (GPL Publications and Projects)

"Henk verhoeven" <news1@phpPeanus_RemoveThis.orgwrote in message
news:evmde1$fa6$1@news3.zwoll1.ov.home.nl...
Quote:
Hi david,
>
Maybe you could use CONV(`columnname`, 10, 10) in your SQL to convert the
integer to a string before it is passed to php.
>
for example if the colum holding 64 bits integers is named `theInt`:
>
SELECT id, CONV(theInt, 10, 10) FROM yourtable
>
would return the id and theInt columns but theInt converted to a string.
>
Once the string is in php you may use GMP functions for calculations etc.,
see http://nl2.php.net/manual/en/ref.gmp.php
>
Success,
>
Henk Verhoeven,
www.phppeanuts.org.
>
David T. Ashley schreef:
Quote:
>I have a box where I'm forced to use PHP before 64-bit integers became
>standard ...
>>
>If I run a MySQL query where one of the fields returned is 64-bit
>integer, how do I get this into PHP as a string? My recollection is that
>in the result sets it "auto types" so that it is an integer, and 64-bit
>integers will cause problems if one tries to assign into 32 bits.
>>
>P.S.--Once into PHP as a string, I would use the bcmath library to
>manipulate it ...

 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles