473,396 Members | 1,833 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,396 software developers and data experts.

Constant for maximum integer value?

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
Nov 15 '08 #1
7 6979
la***********@zipmail.com wrote:
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.
js*******@attglobal.net
==================
Nov 15 '08 #2
On Nov 15, 4:32*pm, Jerry Stuckle <jstuck...@attglobal.netwrote:
laredotorn...@zipmail.com wrote:
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
Nov 15 '08 #3
la***********@zipmail.com wrote:
On Nov 15, 4:32 pm, Jerry Stuckle <jstuck...@attglobal.netwrote:
>laredotorn...@zipmail.com wrote:
>>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.
js*******@attglobal.net
==================
Nov 15 '08 #4
nadia schreef:
On Sat, 15 Nov 2008 14:11:33 -0800 (PST), "la***********@zipmail.com"
<la***********@zipmail.comwrote:
>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
Nov 17 '08 #5
Erwin Moller escribió:
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
--
Nov 17 '08 #6
nadia schreef:
On Mon, 17 Nov 2008 16:09:13 +0100, "Álvaro G. Vicario"
<al****************@demogracia.comwrote:
>Erwin Moller escribió:
>>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
Nov 17 '08 #7
nadia schreef:
>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
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

>
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
Nov 17 '08 #8

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

Similar topics

2
by: Hennie de Nooijer | last post by:
Because of an error in google or underlying site i can reply on my own issue. Therefore i copied the former entered message in this message....
6
by: cipher | last post by:
I have some constant values in my web service that my client application will require. Having to keep server side and client side definitions insync is tedious. I am trying to do something like...
3
by: yawnmoth | last post by:
I'm trying to figure out how big integers in PHP can be and am having some difficulty. My first idea was to try something like this: <? for ($bits=0; (1<<($bits+1)) > (1<<$bits); $bits++);...
6
by: fctk | last post by:
hello, i'm trying to compile this small program: int main(void) { unsigned long int max; max = 4000000000;
29
by: garyusenet | last post by:
I'm trying to investigate the maximum size of different variable types. I'm using INT as my starting variable for exploration. I know that the maximum number that the int variable can take is:...
2
by: Pugi! | last post by:
hi, I am using this code for checking wether a value (form input) is an integer and wether it is smaller than a given maximum and greater then a given minimum value: function...
4
by: Felix Kater | last post by:
Hi, when I use something like int Shift= 3; long Value= 1 << Shift; What is the data type of the const value '1' here? In other terms: What is the possible maximum of 'Shift' here?
33
by: desktop | last post by:
In the C++ standard sec 23.1.2 table 69 it says that erase(q) where q is a pointer to an element can be done in amortized constant time. I guess that is not worst case since std::set is...
26
by: kerravon | last post by:
The following C program: int main(void) { int x = -2147483648; return (0); } Produces the following warning:
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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...

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.