Connecting Tech Pros Worldwide Help | Site Map

Constant for maximum integer value?

laredotornado@zipmail.com
Guest
 
Posts: n/a
#1: Nov 15 '08
Hi,

I'm using PHP 5 with MySql 5. I have a MySQL InnoDB table with a
column of type INTEGER UNSIGNED. Is there a constant in PHP to insert
the maximum value possible into the column? The underlying OS is Red
Hat Linux, but I'm not sure about the version.

Any help you can provide is appreciated, - Dave
Jerry Stuckle
Guest
 
Posts: n/a
#2: Nov 15 '08

re: Constant for maximum integer value?


laredotornado@zipmail.com wrote:
Quote:
Hi,
>
I'm using PHP 5 with MySql 5. I have a MySQL InnoDB table with a
column of type INTEGER UNSIGNED. Is there a constant in PHP to insert
the maximum value possible into the column? The underlying OS is Red
Hat Linux, but I'm not sure about the version.
>
Any help you can provide is appreciated, - Dave
The maximum in PHP does not necessarily equate to the maximum in MySQL.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
laredotornado@zipmail.com
Guest
 
Posts: n/a
#3: Nov 15 '08

re: Constant for maximum integer value?


On Nov 15, 4:32*pm, Jerry Stuckle <jstuck...@attglobal.netwrote:
Quote:
laredotorn...@zipmail.com wrote:
Quote:
Hi,
>
Quote:
I'm using PHP 5 with MySql 5. *I have a MySQL InnoDB table with a
column of type INTEGER UNSIGNED. *Is there a constant in PHP to insert
the maximum value possible into the column? *The underlying OS is Red
Hat Linux, but I'm not sure about the version.
>
Quote:
Any help you can provide is appreciated, - Dave
>
The maximum in PHP does not necessarily equate to the maximum in MySQL.
>
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attglobal.net
==================
When I said "to insert the maximum value in the column", I meant the
maximum value that MySQL will allow. Is there a PHP expression that
can evaluate to the maximum unsigned integer in MySQL or do I just
need to hard code the maximum number in my code? - Dave
Jerry Stuckle
Guest
 
Posts: n/a
#4: Nov 15 '08

re: Constant for maximum integer value?


laredotornado@zipmail.com wrote:
Quote:
On Nov 15, 4:32 pm, Jerry Stuckle <jstuck...@attglobal.netwrote:
Quote:
>laredotorn...@zipmail.com wrote:
Quote:
>>Hi,
>>I'm using PHP 5 with MySql 5. I have a MySQL InnoDB table with a
>>column of type INTEGER UNSIGNED. Is there a constant in PHP to insert
>>the maximum value possible into the column? The underlying OS is Red
>>Hat Linux, but I'm not sure about the version.
>>Any help you can provide is appreciated, - Dave
>The maximum in PHP does not necessarily equate to the maximum in MySQL.
>>
>--
>==================
>Remove the "x" from my email address
>Jerry Stuckle
>JDS Computer Training Corp.
>jstuck...@attglobal.net
>==================
>
When I said "to insert the maximum value in the column", I meant the
maximum value that MySQL will allow. Is there a PHP expression that
can evaluate to the maximum unsigned integer in MySQL or do I just
need to hard code the maximum number in my code? - Dave
What you need then is the maximum MySQL value, not the maximum PHP
value. They are two different things.

Try comp.databases.mysql.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
Erwin Moller
Guest
 
Posts: n/a
#5: Nov 17 '08

re: Constant for maximum integer value?


nadia schreef:
Quote:
On Sat, 15 Nov 2008 14:11:33 -0800 (PST), "laredotornado@zipmail.com"
<laredotornado@zipmail.comwrote:
>
Quote:
>Hi,
>>
>I'm using PHP 5 with MySql 5. I have a MySQL InnoDB table with a
>column of type INTEGER UNSIGNED. Is there a constant in PHP to insert
>the maximum value possible into the column? The underlying OS is Red
>Hat Linux, but I'm not sure about the version.
>>
>Any help you can provide is appreciated, - Dave
>
Dave - PHP (very annoyingly) only provides a signed 32 bit integer.
That means that's the highest integer you can use.
My guess is your database has an unsigned 32 bit integer type leaving
you dangling in the wind if you don't know about this. We had a similar problem
we had to work around using sprintf() - that only works up to a certain value
also. (Our problem was related to file sizes which for video's is a serious
drawback to using PHP)
>
nadia
>
Nadia, just curious: Are you claiming you didn't have enough room in a
32 bit integer to store the file size of a video?
If not, what did go wrong?

Anyway, if you need Big Numbers and want to be excact, try BC Math
Functions:
http://nl3.php.net/manual/en/ref.bc.php

Regards,
Erwin Moller


--
"There are two ways of constructing a software design: One way is to
make it so simple that there are obviously no deficiencies, and the
other way is to make it so complicated that there are no obvious
deficiencies. The first method is far more difficult."
-- C.A.R. Hoare
=?ISO-8859-1?Q?=22=C1lvaro_G=2E_Vicario=22?=
Guest
 
Posts: n/a
#6: Nov 17 '08

re: Constant for maximum integer value?


Erwin Moller escribió:
Quote:
Nadia, just curious: Are you claiming you didn't have enough room in a
32 bit integer to store the file size of a video?
Let me answer. Believe it or not, that's true. But that's not all. There
doesn't seem to be any simple way to get the size of file that's larger
than 4GB (i.e., 2^32 bytes). Function filesize() won't return the right
size.



--
-- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web: http://bits.demogracia.com
-- Mi web de humor al baño María: http://www.demogracia.com
--
Erwin Moller
Guest
 
Posts: n/a
#7: Nov 17 '08

re: Constant for maximum integer value?


nadia schreef:
Quote:
On Mon, 17 Nov 2008 16:09:13 +0100, "Álvaro G. Vicario"
<alvaroNOSPAMTHANKS@demogracia.comwrote:
>
Quote:
>Erwin Moller escribió:
Quote:
>>Nadia, just curious: Are you claiming you didn't have enough room in a
>>32 bit integer to store the file size of a video?
>Let me answer. Believe it or not, that's true. But that's not all. There
>doesn't seem to be any simple way to get the size of file that's larger
>than 4GB (i.e., 2^32 bytes). Function filesize() won't return the right
>size.
>
>
Thank you Alvaro - thats the point I was making exactly.
>
Nadia
>
Hi,

Hmm, I never worked with such huge files, but I imagine that must be
really annoying.
How do you solve that problem?
Do you resort to *nix commands (and pass them to exec() and the like) to
get the info you want?

Regards,
Erwin Moller


--
"There are two ways of constructing a software design: One way is to
make it so simple that there are obviously no deficiencies, and the
other way is to make it so complicated that there are no obvious
deficiencies. The first method is far more difficult."
-- C.A.R. Hoare
Erwin Moller
Guest
 
Posts: n/a
#8: Nov 17 '08

re: Constant for maximum integer value?


nadia schreef:
Quote:
Quote:
>Nadia, just curious: Are you claiming you didn't have enough room in a
>32 bit integer to store the file size of a video?
>If not, what did go wrong?
>>
>Anyway, if you need Big Numbers and want to be excact, try BC Math
>Functions:
>http://nl3.php.net/manual/en/ref.bc.php
>>
>
Erwin - see my response to Alvaro.
>
In the end we changed the applicaion to borland delphi and did it that way.
We came across a couple of hidden issues with PHP we just couldn't work
around.
>
As someone said here some time ago - PHP is a fantastic script language
but for anything serious you really should go to a full blown compiled language.
At least our experience has led us to believe this also.
Hi,

I don't want to be picky, but I believe I only build serious webapps in
PHP.
I don't think you can say in general that if you need to build anything
serious you cannot use PHP.

Allthough I feel your pain when you cannot get the filesize when a file
Quote:
4GB. That really is a problem I wasn't aware of.
Can you give me more problems you encountered with PHP that made you
'fallback' to Delphi? (No pun intended to Delphi at all)
I am curious since it is better to know this kind of things before I
screw up some project. ;-)

Regards,
Erwin Moller

Quote:
>
nadia.
>

--
"There are two ways of constructing a software design: One way is to
make it so simple that there are obviously no deficiencies, and the
other way is to make it so complicated that there are no obvious
deficiencies. The first method is far more difficult."
-- C.A.R. Hoare
Closed Thread