473,398 Members | 2,188 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

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 (dt*@e3ft.com)
http://www.e3ft.com (Consulting Home Page)
http://www.dtashley.com (Personal Home Page)
http://gpl.e3ft.com (GPL Publications and Projects)
Apr 11 '07 #1
2 1954
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:
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 ...
Apr 12 '07 #2
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 (dt*@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:ev**********@news3.zwoll1.ov.home.nl...
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:
>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 ...

Apr 13 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Marc Poinot | last post by:
Did anybody use numarray on a 64 bits platform ? (e.g. SGI/Irix) The package works on our 64 bits platforms... using 32 bits mode, but not using 64 mode. Big crash in _ufunc... Is there a flag to...
1
by: Hugo | last post by:
I have a dual boot machine, runs Win XP pro and Win XP Pro 64, XP boots from C and XP 64 boots from D. They both have VS 2005 Beta 2 installed. I have a webapp developed in Win XP (32) which...
3
by: Odd Bjørn Andersen | last post by:
I was asked to install db2 udb workgroup edition (version 7.2) 64-bits on AIX. But I cannot find that we have a CD with that software. Only Enterprise Edition. Is it correct that you have to...
56
by: Dave Vandervies | last post by:
I just fixed a bug that some of the correctness pedants around here may find useful as ammunition. The problem was that some code would, very occasionally, die with a segmentation violation...
0
by: Hugo | last post by:
I have a dual boot machine, runs Win XP pro and Win XP Pro 64, Win XP boots from C and Win XP 64 boot from D. They both have VS 2005 Beta 2 installed. I have a webapp developed in Win XP (32)...
3
by: some one | last post by:
I have kind of wired problem, I using httpwebrequest to post form data to server , in the GetResponse stage a WebException occurred, after tracing the actual error that occurs on the server, I...
1
by: mel_apiso | last post by:
Hi, we have an AIX 5.3 OS, and we purchased DB2 UDB version 8 Workgroup Edition. We want to install 64 bits version, but the source CD's that we have say: WORKGROUP SERVER EDITION Version...
13
by: Mary Lei | last post by:
Does anyone know the link to obtain the tarball for db2 8.1 for solaris running on AMD 64 bit ? This is the entire db2 installation on a new system that does not have db2. Thanks.
10
by: krunalb | last post by:
Hi, I am trying to shift unsigned long long value by 64 bits and this is what i get #include <stdio.h> int main() { unsigned short shiftby= 64;
1
by: =?Utf-8?B?UGF1bCBQaGlsbGlwcw==?= | last post by:
I have read many things about this but I haven't got a clear vision on what to do if anything about this. I have a system that tries to find holes in my web site. One of the things it has...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.