1
0
mirror of https://github.com/VCMP-SqMod/SqMod.git synced 2025-06-16 15:17:13 +02:00

Implement field selection in the MySQL library.

This commit is contained in:
Sandu Liviu Catalin
2020-04-10 10:12:05 +03:00
parent a7f8584661
commit 15532298dc
4 changed files with 71 additions and 6 deletions

View File

@ -540,19 +540,22 @@ public:
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
template<class F>
void Foreach(F&& func) const
SQRESULT Foreach(F&& func) const
{
const StackGuard sg(vm);
sq_pushobject(vm,obj);
sq_pushnull(vm);
while(SQ_SUCCEEDED(sq_next(vm,-2)))
SQRESULT res = SQ_OK;
for(SQInteger i = 0; SQ_SUCCEEDED(sq_next(vm,-2)); ++i)
{
if (!func(vm))
res = func(vm, i);
if (SQ_FAILED(res))
{
return;
break;
}
sq_pop(vm,2);
}
return res;
}
protected: