Re: Select record by ID
| From: | Richard Lynch | Date: | Tue, 30 Jan 2007 01:19:33 +0000 |
| Subject: | Re: Select record by ID | ||
| References: | 1 2 3 4 5 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-247991@lists.php.net to get a copy of this message | ||
On Mon, January 29, 2007 6:55 pm, Roman Neuhauser wrote:
> # ceo@l-i-e.com / 2007-01-29 17:54:03 -0600:
>> MySQL is the *only* db engine that lets you get away with [bleep]
>> like
>> apostrophes around numbers.
>
> Actually, these are examples of valid SQL: INTEGER '1', FLOAT '13.5'.
> test=# select float '13.5' * integer '10';
> ?column?
> ----------
> 135
> (1 row)
Errrr.
Yes, you can TYPE-CAST string data into integer/float data...
But you are INPUTTING string data at that point, not numeric, and
forcing PostgreSQL to convert it internally.
It's the exact analog of:
<?php
$foo = '1';
$foo = (int) $foo;
echo gettype($foo);
$bar = 1;
echo gettype($bar);
?>
> test=# create table t (f float, i integer);
> CREATE TABLE
> test=# insert into t values ('13.5', '10');
> INSERT 0 1
> test=# select * from t;
> f | i
> ------+----
> 13.5 | 10
> (1 row)
I'm amazed this worked and didn't error out...
It definitely USED to error out.
Looks like PostgreSQL caved in to the unwashed masses of MySQL users
who couldn't handle not putting apostrophes around everything to me...
[sigh]
:-) :-) :-)
Oh well.
I personally would prefer that the DB not accept bogus input like this.
Different strokes for different folks.
--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?