1
0
mirror of https://github.com/VCMP-SqMod/SqMod.git synced 2024-11-08 00:37:15 +01:00

Add Exec[Async] shotrcuts to session.

This commit is contained in:
Sandu Liviu Catalin 2021-02-03 16:54:36 +02:00
parent 8607c65872
commit 09a1767ffe
2 changed files with 38 additions and 0 deletions

View File

@ -111,6 +111,32 @@ SqDataStatement SqDataSession::GetStatement(StackStrF & data)
return SqDataStatement(*this, data);
}
// ------------------------------------------------------------------------------------------------
SqDataSession & SqDataSession::Execute(StackStrF & query)
{
// Create a statement instance
Statement stmt(impl()->createStatementImpl());
// Add the query to the
stmt << (query);
// Execute it
stmt.execute();
// Allow chaining
return *this;
}
// ------------------------------------------------------------------------------------------------
SqDataSession & SqDataSession::ExecuteAsync(StackStrF & query)
{
// Create a statement instance
Statement stmt(impl()->createStatementImpl());
// Add the query to the
stmt << (query);
// Execute it
stmt.executeAsync();
// Allow chaining
return *this;
}
// ------------------------------------------------------------------------------------------------
void SqDataStatement::UseEx(LightObj & obj, const std::string & name, Poco::Data::AbstractBinding::Direction dir)
{
@ -426,6 +452,8 @@ void Register_POCO_Data(HSQUIRRELVM vm, Table &)
.FmtFunc(_SC("GetFeature"), &SqDataSession::GetFeature)
.FmtFunc(_SC("SetProperty"), &SqDataSession::SetProperty)
.FmtFunc(_SC("GetProperty"), &SqDataSession::GetProperty)
.FmtFunc(_SC("Execute"), &SqDataSession::Execute)
.FmtFunc(_SC("ExecuteAsync"), &SqDataSession::ExecuteAsync)
// Static Functions
.StaticFunc(_SC("GetURI"), &SqDataSession::BuildURI)
// Static Values

View File

@ -788,6 +788,16 @@ struct SqDataSession : public Session
* Look up the value of a property.
*/
SQMOD_NODISCARD SqDataStatement GetStatement(StackStrF & data);
/* --------------------------------------------------------------------------------------------
* Create a statement and execute the given query immediately.
*/
SqDataSession & Execute(StackStrF & query);
/* --------------------------------------------------------------------------------------------
* Create a statement and execute the given query whenever possible.
*/
SqDataSession & ExecuteAsync(StackStrF & query);
};
/* ------------------------------------------------------------------------------------------------