Fix return types from AsyncMysql queries (allow NULLS, support variants)

We did not properly export NULL values as null; instead they
appeared as empty strings.  In addition, we returned all ints, floats,
etc, as strings rather than properly typed.

This diff adds support for typed return values (ie, ints, floats, etc)
rather than just strings.  It also changes returned maps and vectors to
have actual null values when the underlying result set returned nulls.
Esse commit está contido em:
Chip Turner
2013-07-23 21:45:54 -07:00
commit de Sara Golemon
commit c051b9c3c2
2 arquivos alterados com 9 adições e 1 exclusões
+8 -1
Ver Arquivo
@@ -796,8 +796,15 @@ Variant f_mysql_affected_rows(CVarRef link_identifier /* = uninit_null() */) {
///////////////////////////////////////////////////////////////////////////////
// query functions
// Zend returns strings and NULL only, not integers or floats. We
// return ints (and, sometimes, actual doubles). TODO: make this
// consistent or a runtime parameter or something.
Variant mysql_makevalue(CStrRef data, MYSQL_FIELD *mysql_field) {
switch (mysql_field->type) {
return mysql_makevalue(data, mysql_field->type);
}
Variant mysql_makevalue(CStrRef data, enum_field_types field_type) {
switch (field_type) {
case MYSQL_TYPE_DECIMAL:
case MYSQL_TYPE_TINY:
case MYSQL_TYPE_SHORT:
+1
Ver Arquivo
@@ -310,6 +310,7 @@ Variant f_mysql_affected_rows(CVarRef link_identifier = uninit_null());
// query functions
Variant mysql_makevalue(CStrRef data, MYSQL_FIELD *mysql_field);
Variant mysql_makevalue(CStrRef data, enum_field_types field_type);
bool f_mysql_set_timeout(int query_timeout_ms = -1,
CVarRef link_identifier = uninit_null());