[ciapug] weakly typed languages, etc.
carl-olsen at mchsi.com
carl-olsen at mchsi.com
Wed Apr 4 13:35:28 CDT 2007
I see what you are saying now. MySQL would not throw an error if it accepts quotes around integers. Some databases would throw an error if you did that. PHP is going to take care of it by sending an integer value in the static version of the SQL query it sends to the database. Perhaps MySQL will accept it either way and other databases would not. The behavior is intentional and that's about the only reason I can think of where it would be useful. You can't use a variable in Java or C# without declaring its value type first.
-------------- Original message ----------------------
From: David Champion <dchampion at visionary.com>
> That's not being evaluated by PHP, it's being evaluated by MySQL.
> Different issue.
>
> If you go into MySQL and type the query with the quotes around the value
> it will work just fine.
>
> -dc
>
> carl-olsen at mchsi.com wrote:
> > I've noticed a lot of books do a MySQL query like so "SELECT * FROM table
> WHERE id = '1'".
> >
> > If PHP did not convert that quoted number into an integer, it would throw an
> error.
> >
> > Most other databases would through an error if you put quotes around an
> integer in the WHERE clause.
> >
> >
> > -------------- Original message ----------------------
> > From: carl-olsen at mchsi.com
> >> concatenate "s" to the beginning of each string, then do the comparison, and
> >> finally strip "s" from the beginning of each string. Actually, adding any
> >> "alpha" character to the string will prevent PHP from converting it to a
> number.
> >> _______________________________________________
> >> ciapug mailing list
> >> ciapug at cialug.org
> >> http://cialug.org/mailman/listinfo/ciapug
> >
> >
> > _______________________________________________
> > ciapug mailing list
> > ciapug at cialug.org
> > http://cialug.org/mailman/listinfo/ciapug
> >
>
>
> _______________________________________________
> ciapug mailing list
> ciapug at cialug.org
> http://cialug.org/mailman/listinfo/ciapug
More information about the ciapug
mailing list