Hello,
is there a reason (technical or historical) why the data coming from MySQL is 
always strings?
I've found only one case where the data type is "honored" - 
PDO+mysqlnd+emulation off [1]

We made a fairly simple patch to 'mysqlnd' which enables (configurable via ini) 
data to be returned (trying to match) as defined in database/table. 

In general something like:

switch( field->type ){
        case MYSQL_TYPE_TINY:
        case MYSQL_TYPE_SHORT:
        case MYSQL_TYPE_LONG:
        case MYSQL_TYPE_LONGLONG:
        case MYSQL_TYPE_INT24:
                convert_to_long(data);
                break;
        case MYSQL_TYPE_DECIMAL:
        case MYSQL_TYPE_DOUBLE:
        case MYSQL_TYPE_FLOAT:
        case MYSQL_TYPE_NEWDECIMAL:
                convert_to_double(data);
                break;
}

Does it make sense to create a PR and/or RFC for something like this?


[1] https://phpdelusions.net/pdo#returntypes


wbr
Reinis Rozitis


--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to