mysql - Why PHP return STRING instead of INT -


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.

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

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

  1. flexablity: can handle everything

string can contain every datatype except binary(blob) format.!

thank you.


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -