Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

The Database Forum


You are currently viewing our The Database Forum as a guest. Please register to participate.
Login



Reply
SQL: Quotes arround the values of numeric columns?
Old 03-10-2009, 03:17 AM SQL: Quotes arround the values of numeric columns?
Junior Talker

Posts: 2
Trades: 0
Hello,

I must modify an application build with MySQL to make it work with other databases.

This application works perfectly but use quotes in all the requests even for numeric columns.

For example:
SELECT * FROM table WHERE id='1'

(where id is declared as INTEGER)

Do you know if this syntax is accepted by all databases?
dimalta is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 03-10-2009, 03:52 AM Re: SQL: Quotes arround the values of numeric columns?
NullPointer's Avatar
Will Code for Food

Posts: 2,787
Name: Matt
Location: Irvine, CA
Trades: 0
I think most DBs would know to parse it as an int (I know mysql and mssql will). If you're working in PHP, using PDO might simplify the process of making your application more portable:

http://www.google.com/search?hl=en&q...earch&aq=f&oq=

Using your example with PDO:

PHP Code:
$id 1;

$db = new PDO();
$stmt $db->prepare('SELECT * FROM table WHERE id=?');
$stmt->bindParam(1$id);
$stmt->execute(); 
In the example above you don't have to worry about quotes, even for strings.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
NullPointer is online now
Reply With Quote
View Public Profile Visit NullPointer's homepage!
 
Old 03-10-2009, 04:41 AM Re: SQL: Quotes arround the values of numeric columns?
Junior Talker

Posts: 2
Trades: 0
Thank for your answer, so I can add MSSQL to my list of compatibles databases. At this time MySQL, Oracle, MSSQL, PostgreSQL and SQLite seem to be compatible.

Yes I plan on using PDO

Unfortunately due to the structure of the application (and many generated requests) I will not be able to use prepare() all the time. The code is not really compatible with this new approach that comes with PDO.

I will be able to support only the databases compatible with this syntax, the more they are, the best it is for me in this case.

Other compatible databases??

Last edited by dimalta; 03-10-2009 at 04:45 AM..
dimalta is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to SQL: Quotes arround the values of numeric columns?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.17551 seconds with 12 queries