diff --git a/a8/mysql.cc b/a8/mysql.cc index 2fcac89..1aefde4 100644 --- a/a8/mysql.cc +++ b/a8/mysql.cc @@ -192,6 +192,12 @@ namespace a8 return impl_->mysqlres ? mysql_num_rows(impl_->mysqlres) : 0; } + int Query::FieldsNum() + { + assert(impl_->mysqlres); + return impl_->mysqlres ? mysql_num_fields(impl_->mysqlres) : 0; + } + bool Query::Eof() { assert(impl_->mysqlres); diff --git a/a8/mysql.h b/a8/mysql.h index 8e045f8..2299d06 100644 --- a/a8/mysql.h +++ b/a8/mysql.h @@ -38,6 +38,7 @@ namespace a8 std::string FormatSqlEx(const char* fmt, std::initializer_list args); std::string FormatSql(const char* fmt, std::initializer_list& args); int RowsNum(); + int FieldsNum(); bool Eof(); void First(); void Prev(); diff --git a/a8/xvalue.cc b/a8/xvalue.cc index 90852ca..54909f2 100644 --- a/a8/xvalue.cc +++ b/a8/xvalue.cc @@ -119,15 +119,21 @@ namespace a8 void XValue::Set(long v) { OnReset(); - type_ = XVT_INT; - value_.int_value = v; + if (sizeof(long) == 8) { + Set((long long)v); + } else { + Set((int)v); + } } void XValue::Set(unsigned int v) { OnReset(); - type_ = XVT_UINT; - value_.int_value = v; + if (sizeof(long) == 8) { + Set((unsigned long long)v); + } else { + Set((unsigned int)v); + } } void XValue::Set(unsigned long v) @@ -407,12 +413,20 @@ namespace a8 XValue::operator long() const { - return GetInt(); + if (sizeof(long) == 8) { + return GetInt64(); + } else { + return GetInt(); + } } XValue::operator unsigned long() const { - return GetUInt(); + if (sizeof(long) == 8) { + return GetUInt64(); + } else { + return GetUInt(); + } } XValue::operator double() const