I thought I could share what I have. Since native_type and pdo_type return such very different values, I use "len" to try to check the lines and text, since everything less than 255 is var char, int or boolean. In addition, pdo_type has only 5 possible values.
//PDO data types $types = array( PDO::PARAM_BOOL => 'bool', PDO::PARAM_NULL => 'null', PDO::PARAM_INT => 'int', PDO::PARAM_STR => 'string', PDO::PARAM_LOB => 'blob', PDO::PARAM_STMT => 'statement' //Not used right now ); //Get meta $column = $result->getColumnMeta(1); //If the column lenght isn't set - default to ZERO $column['len'] = isset($column['len']) ? $column['len'] : 0; //HACK: If it is longer than 255 chars then it is a text area if($column['len'] > 255) { $column['type'] = 'text'; } else { $column['type'] = $types[$column['pdo_type']]; }
source share