RE: error when trying to delete a record

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

 



[snip]
Is the above statement true when the id field is numeric (which it
surely is
in this case)? I get the expected results (in mySQL) when using
statements
like

SELECT name FROM table WHERE id=1

with no single quotes round it. Putting quotes round integer values is
counter-intuitive - is it necessary in some cases?
[/snip]

If the id field is numeric and the $id is not set the query will return
a syntax error due to the query being seen as this...

SELECT foo FROM bar WHERE id = ;

The problems multiply when the id field is of the auto-increment type.
Some RDBMS have settings that will allow conditionals, such as WHERE
id=1, to be evaluated as TRUE or FALSE, which accounts for my previous
statement. id, in this case, may be a bad example because most
developers would like a more qualified conditional match before a
deletion occurs. I would never let my development team use the id (or
whatever it was called, especially an auto-increment field) for record
retrieval or deletion. In general you would not have to use quotes
around fields that are INTs, FLOATs, etc.

P.S. Paul, click reply-all when sending messages back to this list. I
know it is counter-intuitive, but it is how this one works.

-- 
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