C++ Web Framework  3.0
Public Member Functions | List of all members
SqlQuery Class Reference

The SqlQuery class was created to facilitate integration with SqlDataBaseStorage and manipulation to the database through JSON. More...

#include <sqlquery.h>

Inheritance diagram for SqlQuery:
Inheritance graph
[legend]

Public Member Functions

 SqlQuery (SqlDatabaseStorage &dbStorage)
 Constructs a QSqlQuery object using the database dbStorage. More...
 
QJsonObject exec ()
 Executes and returns a JSON indicating success, or failure through the key success. More...
 
QJsonObject exec (const QString &query)
 Executes a query and returns a JSON indicating success, or failure through the key "success" and "message". More...
 
QJsonArray toJson ()
 Returns the result of a select converted to a QJsonArray. If there is a failure, a JSON object with two fields will be returned: "success" and "message". If there are no results, QJsonArray will return a empty object. More...
 
QJsonObject deleteRecord (const QString &table, const QString &condition)
 Delete a record given a table and a condition. Returns a JSON indicating success, or failure through the key "success" and "message". More...
 
QJsonObject insertFromJson (const QJsonObject &json, const QString &table)
 Insert a record given a json and a table. Returns a JSON indicating success, or failure through the key "success" and "message". More...
 
QJsonObject updateFromJson (const QJsonObject &json, const QString &table, const QString &condition)
 Update a record given a json, a table and a condition. Returns a JSON indicating success, or failure through the key "success" and "message". More...
 

Detailed Description

The SqlQuery class was created to facilitate integration with SqlDataBaseStorage and manipulation to the database through JSON.

Constructor & Destructor Documentation

◆ SqlQuery()

CWF_BEGIN_NAMESPACE SqlQuery::SqlQuery ( SqlDatabaseStorage dbStorage)
explicit

Constructs a QSqlQuery object using the database dbStorage.

Parameters
dbStorage

Member Function Documentation

◆ deleteRecord()

QJsonObject SqlQuery::deleteRecord ( const QString &  table,
const QString &  condition 
)

Delete a record given a table and a condition. Returns a JSON indicating success, or failure through the key "success" and "message".

Parameters
table
condition
Returns
QJsonObject

◆ exec() [1/2]

QJsonObject SqlQuery::exec ( )

Executes and returns a JSON indicating success, or failure through the key success.

Returns
QJsonObject

◆ exec() [2/2]

QJsonObject SqlQuery::exec ( const QString &  query)

Executes a query and returns a JSON indicating success, or failure through the key "success" and "message".

Returns
QJsonObject

◆ insertFromJson()

QJsonObject SqlQuery::insertFromJson ( const QJsonObject &  json,
const QString &  table 
)

Insert a record given a json and a table. Returns a JSON indicating success, or failure through the key "success" and "message".

Parameters
json
table
Returns
QJsonObject

◆ toJson()

QJsonArray SqlQuery::toJson ( )

Returns the result of a select converted to a QJsonArray. If there is a failure, a JSON object with two fields will be returned: "success" and "message". If there are no results, QJsonArray will return a empty object.

Returns
QJsonArray

◆ updateFromJson()

QJsonObject SqlQuery::updateFromJson ( const QJsonObject &  json,
const QString &  table,
const QString &  condition 
)

Update a record given a json, a table and a condition. Returns a JSON indicating success, or failure through the key "success" and "message".

Parameters
json
table
Returns
QJsonObject

The documentation for this class was generated from the following files: