Page 1 of 1

Db storage string or int

Posted: Fri Aug 24, 2007 11:34 pm
by kkonline
In the database, i have a table storage

In the processing page i write

Code: Select all

$sql="INSERT INTO storage (tags,trusted)VALUES('$tags','0')";
The table storage has tags as text and trusted as tinyint(1);

The above query send trusted values as a string(i think) but in db it's of tinyint(1)

So is there any need to send values as

Code: Select all

VALUES('$tags',0)
INSTEAD OF

Code: Select all

VALUES('$tags','0')
Or it will be type converted automatically?

Posted: Sat Aug 25, 2007 1:54 am
by Christopher
What kind of database? Have you tried it to see what it does?

Posted: Sat Aug 25, 2007 4:16 am
by xpgeek
No needs to alter table.

It's automatical converted you string value into integer.

Re: Db storage string or int

Posted: Sat Aug 25, 2007 11:27 am
by califdon
kkonline wrote:

Code: Select all

VALUES('$tags',0)
INSTEAD OF

Code: Select all

VALUES('$tags','0')
Although the database engine might convert, you should send it as the correct data type. There's no point in deliberately sending the wrong data type.