mysql - Why PHP return STRING instead of INT -
this question has answer here:
a simple question,
why php fetch()
transform int
string
?
example :
- database structure :
is_active int(11)
- php fetch :
'is_active' => string '1' (length=1)
in opinion, it's trading off of performance , accessibility.
in short, if mysql uses one-type(string) data, containers may have one-type tuple , not need complex data structure.
- there various datatypes various database.
for example, int easy data-type. there int32, int64, unsigned int , every-databases has own data-type, php simplify type it. ie. cannot simple varchar2 converted string since there text, varchar, varchar2, string.
- easy beginners
in opinion, advantage of php is easy beginners use. if php took type database. have object such dbresult { enum datatype, object dataset }
it seems complex , increase size of code.
- flexablity: can handle everything
string can contain every datatype except binary(blob) format.!
thank you.
Comments
Post a Comment