This commit is contained in:
aozhiwei 2018-11-08 14:02:43 +08:00
commit 70de530831
3 changed files with 27 additions and 6 deletions

View File

@ -192,6 +192,12 @@ namespace a8
return impl_->mysqlres ? mysql_num_rows(impl_->mysqlres) : 0; 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() bool Query::Eof()
{ {
assert(impl_->mysqlres); assert(impl_->mysqlres);

View File

@ -38,6 +38,7 @@ namespace a8
std::string FormatSqlEx(const char* fmt, std::initializer_list<a8::XValue> args); std::string FormatSqlEx(const char* fmt, std::initializer_list<a8::XValue> args);
std::string FormatSql(const char* fmt, std::initializer_list<a8::XValue>& args); std::string FormatSql(const char* fmt, std::initializer_list<a8::XValue>& args);
int RowsNum(); int RowsNum();
int FieldsNum();
bool Eof(); bool Eof();
void First(); void First();
void Prev(); void Prev();

View File

@ -119,15 +119,21 @@ namespace a8
void XValue::Set(long v) void XValue::Set(long v)
{ {
OnReset(); OnReset();
type_ = XVT_INT; if (sizeof(long) == 8) {
value_.int_value = v; Set((long long)v);
} else {
Set((int)v);
}
} }
void XValue::Set(unsigned int v) void XValue::Set(unsigned int v)
{ {
OnReset(); OnReset();
type_ = XVT_UINT; if (sizeof(long) == 8) {
value_.int_value = v; Set((unsigned long long)v);
} else {
Set((unsigned int)v);
}
} }
void XValue::Set(unsigned long v) void XValue::Set(unsigned long v)
@ -407,13 +413,21 @@ namespace a8
XValue::operator long() const XValue::operator long() const
{ {
if (sizeof(long) == 8) {
return GetInt64();
} else {
return GetInt(); return GetInt();
} }
}
XValue::operator unsigned long() const XValue::operator unsigned long() const
{ {
if (sizeof(long) == 8) {
return GetUInt64();
} else {
return GetUInt(); return GetUInt();
} }
}
XValue::operator double() const XValue::operator double() const
{ {