|
Posted by tg-php on 10/18/05 22:16
Sorry everyone, I missed the "integer" requirement here. I apologize. And yes, '' isn't a good integer value and will throw an error.
That's what I get for not reading thoroughly enough :)
-TG
= = = Original message = = =
On Tue, October 18, 2005 12:42 pm, tg-php@gryffyndevelopment.com wrote:
> That should work. You can set it so you can't have NULL, but dont
> know of anything that tells the database not to accept '' as a value
Any database, other than MySQL, is *NOT* going to accept '' as an
integer value.
Because '' is not an integer by any stretch of the imagination.
If you don't care about ever porting your application to something
other than MySQL, then you can IGNORE the advice to not use '' on
integers.
If there's ANY possibility that some day somebody might maybe wanna
use a different database with your application, then don't confuse
strings with integers.
Actually, it might be better for your own
education/sanity/comprehension/documentation/code to not confuse
strings and integers with '' around integers in the SQL, but if
everything ELSE is good in your code, and it's "always going to be
MySQL" then it's fine.
Note that:
$value2 = 'NULL'; //PHP $value2 is a string
$query = "insert into (integer_field) values ($value2)";
//PHP $query is a string, but...
The place-holder in $value2 will be just: NULL
No quotes.
No apostrophes.
Not a string.
NULL
SQL NULL value representing "no value"
___________________________________________________________
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.
Navigation:
[Reply to this message]
|