mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2024-11-08 00:37:15 +01:00
More MySQL implementation.
This commit is contained in:
parent
3affe10c35
commit
0d6e80a9d5
@ -89,6 +89,14 @@ public:
|
||||
*/
|
||||
static SQInteger Typename(HSQUIRRELVM vm);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* See whether the managed handle is valid.
|
||||
*/
|
||||
bool IsValid() const
|
||||
{
|
||||
return m_Handle;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Validate the managed connection handle and throw exception if it doesn't exist.
|
||||
*/
|
||||
|
@ -151,7 +151,7 @@ Uint64 ConnHnd::Handle::Execute(CSStr query, Ulong size)
|
||||
size = std::strlen(query);
|
||||
}
|
||||
// Attempt to execute the specified query
|
||||
else if (mysql_real_query(mPtr, query, size) != 0)
|
||||
else if (mysql_query(mPtr, query) != 0)
|
||||
{
|
||||
THROW_CURRENT_HND((*this), "Unable to execute query");
|
||||
}
|
||||
|
@ -218,6 +218,7 @@ void RegisterAPI(HSQUIRRELVM vm)
|
||||
.SquirrelFunc(_SC("_typename"), &Connection::Typename)
|
||||
.Func(_SC("_tostring"), &Connection::ToString)
|
||||
// Properties
|
||||
.Prop(_SC("IsValid"), &Connection::IsValid)
|
||||
.Prop(_SC("Connected"), &Connection::Connected)
|
||||
.Prop(_SC("ErrNo"), &Connection::GetErrNo)
|
||||
.Prop(_SC("ErrStr"), &Connection::GetErrStr)
|
||||
@ -297,7 +298,7 @@ void RegisterAPI(HSQUIRRELVM vm)
|
||||
.SquirrelFunc(_SC("_typename"), &ResultSet::Typename)
|
||||
.Func(_SC("_tostring"), &ResultSet::ToString)
|
||||
// Properties
|
||||
//.Prop(_SC("Connected"), &ResultSet::Connected)
|
||||
.Prop(_SC("IsValid"), &ResultSet::IsValid)
|
||||
// Member Methods
|
||||
.Func(_SC("SetInt8"), &ResultSet::GetInt8)
|
||||
.Func(_SC("SetUint8"), &ResultSet::GetUint8)
|
||||
@ -307,8 +308,13 @@ void RegisterAPI(HSQUIRRELVM vm)
|
||||
.Func(_SC("SetUint32"), &ResultSet::GetUint32)
|
||||
.Func(_SC("SetInt64"), &ResultSet::GetInt64)
|
||||
.Func(_SC("SetUint64"), &ResultSet::GetUint64)
|
||||
.Func(_SC("SetFloat32"), &ResultSet::GetFloat32)
|
||||
.Func(_SC("SetFloat64"), &ResultSet::GetFloat64)
|
||||
.Func(_SC("SetBool"), &ResultSet::GetBoolean)
|
||||
.Func(_SC("SetBoolean"), &ResultSet::GetBoolean)
|
||||
);
|
||||
|
||||
RootTable(vm).Bind(_SC("SqMySQL"), sqlns);
|
||||
}
|
||||
|
||||
} // Namespace:: SqMod
|
||||
|
@ -58,55 +58,127 @@ SQInteger ResultSet::GetInt8(Uint32 idx) const
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
SQInteger ResultSet::GetUint8(Uint32 idx) const
|
||||
{
|
||||
|
||||
// Validate the managed handle and specified index
|
||||
m_Handle.ValidateIndex(idx);
|
||||
// Should we retrieve the value from the bind wrapper?
|
||||
if (m_Handle->mStatement)
|
||||
{
|
||||
return ConvTo< Uint8 >::From(m_Handle->mBinds[idx].mInt64);
|
||||
}
|
||||
// Retrieve the value directly from the row
|
||||
return ConvTo< Uint8 >::From(*reinterpret_cast< Uint8 ** >(m_Handle->mRow)[idx]);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
SQInteger ResultSet::GetInt16(Uint32 idx) const
|
||||
{
|
||||
|
||||
// Validate the managed handle and specified index
|
||||
m_Handle.ValidateIndex(idx);
|
||||
// Should we retrieve the value from the bind wrapper?
|
||||
if (m_Handle->mStatement)
|
||||
{
|
||||
return ConvTo< Int16 >::From(m_Handle->mBinds[idx].mInt64);
|
||||
}
|
||||
// Retrieve the value directly from the row
|
||||
return ConvTo< Int16 >::From(*reinterpret_cast< Int16 ** >(m_Handle->mRow)[idx]);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
SQInteger ResultSet::GetUint16(Uint32 idx) const
|
||||
{
|
||||
|
||||
// Validate the managed handle and specified index
|
||||
m_Handle.ValidateIndex(idx);
|
||||
// Should we retrieve the value from the bind wrapper?
|
||||
if (m_Handle->mStatement)
|
||||
{
|
||||
return ConvTo< Uint16 >::From(m_Handle->mBinds[idx].mInt64);
|
||||
}
|
||||
// Retrieve the value directly from the row
|
||||
return ConvTo< Uint16 >::From(*reinterpret_cast< Uint16 ** >(m_Handle->mRow)[idx]);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
SQInteger ResultSet::GetInt32(Uint32 idx) const
|
||||
{
|
||||
|
||||
// Validate the managed handle and specified index
|
||||
m_Handle.ValidateIndex(idx);
|
||||
// Should we retrieve the value from the bind wrapper?
|
||||
if (m_Handle->mStatement)
|
||||
{
|
||||
return ConvTo< Int32 >::From(m_Handle->mBinds[idx].mInt64);
|
||||
}
|
||||
// Retrieve the value directly from the row
|
||||
return ConvTo< Int32 >::From(*reinterpret_cast< Int32 ** >(m_Handle->mRow)[idx]);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
SQInteger ResultSet::GetUint32(Uint32 idx) const
|
||||
{
|
||||
|
||||
// Validate the managed handle and specified index
|
||||
m_Handle.ValidateIndex(idx);
|
||||
// Should we retrieve the value from the bind wrapper?
|
||||
if (m_Handle->mStatement)
|
||||
{
|
||||
return ConvTo< Uint32 >::From(m_Handle->mBinds[idx].mInt64);
|
||||
}
|
||||
// Retrieve the value directly from the row
|
||||
return ConvTo< Uint32 >::From(*reinterpret_cast< Uint32 ** >(m_Handle->mRow)[idx]);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
Object ResultSet::GetInt64(Uint32 idx) const
|
||||
Int64 ResultSet::GetInt64(Uint32 idx) const
|
||||
{
|
||||
|
||||
// Validate the managed handle and specified index
|
||||
m_Handle.ValidateIndex(idx);
|
||||
// Should we retrieve the value from the bind wrapper?
|
||||
if (m_Handle->mStatement)
|
||||
{
|
||||
return ConvTo< Int64 >::From(m_Handle->mBinds[idx].mInt64);
|
||||
}
|
||||
// Retrieve the value directly from the row
|
||||
return ConvTo< Int64 >::From(*reinterpret_cast< Int64 ** >(m_Handle->mRow)[idx]);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
Object ResultSet::GetUint64(Uint32 idx) const
|
||||
Uint64 ResultSet::GetUint64(Uint32 idx) const
|
||||
{
|
||||
|
||||
// Validate the managed handle and specified index
|
||||
m_Handle.ValidateIndex(idx);
|
||||
// Should we retrieve the value from the bind wrapper?
|
||||
if (m_Handle->mStatement)
|
||||
{
|
||||
return ConvTo< Uint64 >::From(m_Handle->mBinds[idx].mInt64);
|
||||
}
|
||||
// Retrieve the value directly from the row
|
||||
return ConvTo< Uint64 >::From(*reinterpret_cast< Uint64 ** >(m_Handle->mRow)[idx]);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
SQFloat ResultSet::GetFloat32(Uint32 idx) const
|
||||
{
|
||||
|
||||
// Validate the managed handle and specified index
|
||||
m_Handle.ValidateIndex(idx);
|
||||
// Should we retrieve the value from the bind wrapper?
|
||||
if (m_Handle->mStatement)
|
||||
{
|
||||
return ConvTo< Float32 >::From(m_Handle->mBinds[idx].mInt64);
|
||||
}
|
||||
// Retrieve the value directly from the row
|
||||
return ConvTo< Float32 >::From(*reinterpret_cast< Float32 ** >(m_Handle->mRow)[idx]);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
SQFloat ResultSet::GetFloat64(Uint32 idx) const
|
||||
{
|
||||
|
||||
// Validate the managed handle and specified index
|
||||
m_Handle.ValidateIndex(idx);
|
||||
// Should we retrieve the value from the bind wrapper?
|
||||
if (m_Handle->mStatement)
|
||||
{
|
||||
return ConvTo< Float64 >::From(m_Handle->mBinds[idx].mInt64);
|
||||
}
|
||||
// Retrieve the value directly from the row
|
||||
return ConvTo< Float64 >::From(*reinterpret_cast< Float64 ** >(m_Handle->mRow)[idx]);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
|
@ -77,6 +77,14 @@ public:
|
||||
*/
|
||||
static SQInteger Typename(HSQUIRRELVM vm);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* See whether the managed handle is valid.
|
||||
*/
|
||||
bool IsValid() const
|
||||
{
|
||||
return m_Handle;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve a signed 8 bit integer from a field.
|
||||
*/
|
||||
@ -110,12 +118,12 @@ public:
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve a signed 64 bit integer from a field.
|
||||
*/
|
||||
Object GetInt64(Uint32 idx) const;
|
||||
Int64 GetInt64(Uint32 idx) const;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve an unsigned 64 bit integer from a field.
|
||||
*/
|
||||
Object GetUint64(Uint32 idx) const;
|
||||
Uint64 GetUint64(Uint32 idx) const;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve a 32 bit floating point from a field.
|
||||
|
Loading…
Reference in New Issue
Block a user