mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2025-02-21 20:27:13 +01:00
Add a property to the MySQL result-set to retrieve field wrapper instances for all available fields as an array.
This commit is contained in:
parent
f660e2a155
commit
522ae735e1
@ -180,6 +180,33 @@ Array ResultSet::FieldNames() const
|
||||
return arr;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
Array ResultSet::GetFieldsArray() const
|
||||
{
|
||||
SQMOD_VALIDATE_CREATED(*this);
|
||||
// Grab the number of available fields
|
||||
const SQInteger fcount = ConvTo< SQInteger >::From(m_Handle->mFieldCount);
|
||||
// Is there even something to process?
|
||||
if (!fcount)
|
||||
{
|
||||
return Array(DefaultVM::Get(), 0);
|
||||
}
|
||||
// Create a field instance to insert as copy
|
||||
Field field(m_Handle);
|
||||
// Allocate an array with the same amount of elements as the number of fields
|
||||
Array arr(DefaultVM::Get(), fcount);
|
||||
// Iterate over all the available fields and insert them into the created array
|
||||
for (SQInteger n = 0; n < fcount; ++n)
|
||||
{
|
||||
// Update the field index
|
||||
field.SetIndex(ConvTo< Int32 >::From(n));
|
||||
// Insert a copy of the field instance into the array
|
||||
arr.SetValue(n, field);
|
||||
}
|
||||
// Return the resulted array
|
||||
return arr;
|
||||
}
|
||||
|
||||
// ================================================================================================
|
||||
void Register_ResultSet(Table & sqlns)
|
||||
{
|
||||
@ -195,6 +222,7 @@ void Register_ResultSet(Table & sqlns)
|
||||
// Properties
|
||||
.Prop(_SC("IsValid"), &ResultSet::IsValid)
|
||||
.Prop(_SC("FieldNames"), &ResultSet::FieldNames)
|
||||
.Prop(_SC("FieldsArray"), &ResultSet::GetFieldsArray)
|
||||
.Prop(_SC("RowIndex"), &ResultSet::RowIndex)
|
||||
.Prop(_SC("RowCount"), &ResultSet::RowCount)
|
||||
// Member Methods
|
||||
|
@ -197,6 +197,11 @@ public:
|
||||
*/
|
||||
Array FieldNames() const;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Returns an array with wrapper instances for all the field available in the managed result set.
|
||||
*/
|
||||
Array GetFieldsArray() const;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Returns the current position of the row cursor for the last Next().
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user