views:

59

answers:

2

I've pondered this for a long time, but I've never heard an explanation.

I'm guessing that either MySQL's C API is simply not constructed to hand over data in its original type (which sounds like a design flaw), or the original mysql driver (replaced by the mysqli driver) was simply poorly designed and the mysqli driver was trying to be backwards compatible.

I understand PostgreSQL casts types in PHP, for the most part.. why doesn't MySQL? Is it a common practice in other languages and RDBMSes to return all values as a string?

+2  A: 

mysql is old. mysqli is better ('I' stands for 'improved' of course), PDO outclasses all, and at least knows about bin/int/char differences.

Wrikken
+1  A: 

I think that the original MySQL driver was written around 2000/2001 (maybe earlier?). The PHP Data Objects (PDO) class wasn't written until 2004 -- however this goes to show you how much ground PHP has covered in a short amount of time.

When it originated (PHP) it wasn't necessarily well thought out or planned at all, however they've been sorting things out since then.

That and the fact that PHP isn't a strongly typed programming language might explain why...

evolve