SqlDatabaseInterface Class Reference SqlDatabase

#include <sqldatabase.h>

Inheritance diagram for SqlDatabaseInterface:

详细描述

This class provides SQL database functionality. With it it's possible to query sql databases. E.g. Result<SqlDatabaseRef> mySql = SqlDatabaseClasses::MySql().Create(); provides access to mysql databases.

公共成员函数

MAXON_METHOD Result < void >  Init (const String &sqlServer, Int sqlServerPort, const String &sqlUserName, const String &sqlPasswd, const String &sqlDatabase)
MAXON_METHOD Bool   IsConnected () const
MAXON_METHOD Result < void >  QuerySQL (const String &query, Int64 *insertId=nullptr, BaseArray < BaseArray < String >> *result=nullptr)
MAXON_METHOD Result < String QuotedString (const String &text) const
MAXON_METHOD Result < String ReplaceString (const String &text) const

私有成员函数

  MAXON_INTERFACE ( SqlDatabaseInterface , MAXON_REFERENCE_NORMAL , "net.maxon.interface.sqldatabase")

成员函数文档编制

◆  MAXON_INTERFACE()

MAXON_INTERFACE ( SqlDatabaseInterface   ,
MAXON_REFERENCE_NORMAL   ,
"net.maxon.interface.sqldatabase"   
)
private

◆  Init()

MAXON_METHOD Result <void> Init ( const String sqlServer ,
Int   sqlServerPort ,
const String sqlUserName ,
const String sqlPasswd ,
const String sqlDatabase  
)

Opens the connection to a.

参数
[in] sqlServer IP address of the sql server.
[in] sqlServerPort Port of the sql server.
[in] sqlUserName User name at the given sql server.
[in] sqlPasswd Password of the user.
[in] sqlDatabase Opens this database within the sql database on the server. This parameter is optional.
返回
Returns true if opening the database was successful. @MAXON_ANNOTATION{returnsThis}

◆  IsConnected()

MAXON_METHOD Bool IsConnected ( ) const

Determines if the connection to the database has been established.

返回
Returns true if the connection is open, otherwise false.

◆  QuerySQL()

MAXON_METHOD Result <void> QuerySQL ( const String query ,
Int64 insertId = nullptr ,
BaseArray < BaseArray < String >> *  result = nullptr  
)

Sends a query to the database.

参数
[in] query The sql request string. E.g. "SELECT * from mydatabase".
[out] insertId If the query inserted data into the database, this pointer returns the insert id in the database. This parameter is optional.
[out] result If the query returns data it will be filled into this array. This parameter is optional. The outer array contains the number of lines returned by this query. The first line contains the field header names. The inner array the fields per line returned by this query.
返回
Returns true if the query was successful, otherwise false.

◆  QuotedString()

MAXON_METHOD Result < String > QuotedString ( const String text ) const

This functions returns a quoted string usable for sql queries. This function calls internally ReplaceString() to make the given text sql conform.

参数
[in] text The given text the has to be converted.
返回
The converted string.

◆  ReplaceString()

MAXON_METHOD Result < String > ReplaceString ( const String text ) const

This functions converts a string into usable style for sql queries.

参数
[in] text The given text the has to be converted.
返回
The converted string.