Re: Select record by ID

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, January 29, 2007 6:55 pm, Roman Neuhauser wrote:
> # ceo@xxxxxxxxx / 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?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux