mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2024-12-22 03:46:50 +01:00
Finish missing docs for the rest of the database module.
This commit is contained in:
parent
bef76e4adf
commit
3dfa9bd7e8
@ -1,20 +1,31 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="Database" inherits="Reference" version="4.4">
|
||||
<brief_description>
|
||||
Represents a database.
|
||||
</brief_description>
|
||||
<description>
|
||||
Represents a database.
|
||||
Classes inherited from it implement communication with database systems.
|
||||
See [SQLite3Database] for an example.
|
||||
Currently only an sqlite backend is available, however communication with other systems (like MySQL, or PostgreSQL) can be implemented without too much hassle using engine modules.
|
||||
</description>
|
||||
<tutorials>
|
||||
<link title="Simple Database Demo Project">https://github.com/Relintai/pandemonium_demo_projects/tree/master/database/database_simple</link>
|
||||
<link title="Prepared Statement Database Demo Project">https://github.com/Relintai/pandemonium_demo_projects/tree/master/database/prepared_statements</link>
|
||||
<link title="Web Demo Projects">https://github.com/Relintai/pandemonium_demo_projects/tree/master/web</link>
|
||||
</tutorials>
|
||||
<methods>
|
||||
<method name="get_connection">
|
||||
<return type="DatabaseConnection" />
|
||||
<description>
|
||||
Returns a [DatabaseConnection] object which can be used to run queries on the database.
|
||||
Always get a new one, don't store it, as the database backend might give different ones depending on certain factors (like calling threads) for faster operation.
|
||||
</description>
|
||||
</method>
|
||||
</methods>
|
||||
<members>
|
||||
<member name="connection_string" type="String" setter="set_connection_string" getter="get_connection_string" default="""">
|
||||
Connection string used by the backend.
|
||||
</member>
|
||||
</members>
|
||||
<constants>
|
||||
|
@ -1,8 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="DatabaseConnection" inherits="Reference" version="4.4">
|
||||
<brief_description>
|
||||
Represents a connection to a database server.
|
||||
</brief_description>
|
||||
<description>
|
||||
Represents a connection to a database server.
|
||||
Don't create these directly, use the [code]get_connection()[/code] method in [Database] to get one.
|
||||
</description>
|
||||
<tutorials>
|
||||
</tutorials>
|
||||
@ -10,56 +13,69 @@
|
||||
<method name="create_prepared_statement">
|
||||
<return type="PreparedStatement" />
|
||||
<description>
|
||||
Creates a [PreparedStatement] for use with this database connection.
|
||||
</description>
|
||||
</method>
|
||||
<method name="database_connect">
|
||||
<return type="int" enum="Error" />
|
||||
<argument index="0" name="connection_str" type="String" />
|
||||
<description>
|
||||
Connect to the database. The backend will automatically call this.
|
||||
</description>
|
||||
</method>
|
||||
<method name="ensure_version_table_exists">
|
||||
<return type="void" />
|
||||
<description>
|
||||
Ensures that a table that contains the database's verison exists for compatibility checks.
|
||||
</description>
|
||||
</method>
|
||||
<method name="escape">
|
||||
<return type="String" />
|
||||
<argument index="0" name="str" type="String" />
|
||||
<description>
|
||||
Escapes the given [String] using the database backend's excape method.
|
||||
Use it on user input for sanitization.
|
||||
Note that [QueryBuilder] does this where necessary automatically.
|
||||
Also note that when using [PreparedStatement]s this is not needed.
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_owner">
|
||||
<return type="Database" />
|
||||
<description>
|
||||
Returns the owner [Database].
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_query_builder">
|
||||
<return type="QueryBuilder" />
|
||||
<description>
|
||||
Returns a new [QueryBuilder] that is properly set up for this connection.
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_table_builder">
|
||||
<return type="TableBuilder" />
|
||||
<description>
|
||||
Returns a new [TableBuilder] that is properly set up for this connection.
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_table_version">
|
||||
<return type="int" />
|
||||
<argument index="0" name="table" type="String" />
|
||||
<description>
|
||||
Returns the current table version. This can be used to determine database compatibility, or for example whether to run migrations or not during startup.
|
||||
</description>
|
||||
</method>
|
||||
<method name="query">
|
||||
<return type="QueryResult" />
|
||||
<argument index="0" name="query" type="String" />
|
||||
<description>
|
||||
Run a query. Use the resulting[QueryResult] object to read data from the database.
|
||||
</description>
|
||||
</method>
|
||||
<method name="query_run">
|
||||
<return type="void" />
|
||||
<argument index="0" name="query" type="String" />
|
||||
<description>
|
||||
Run a query.
|
||||
</description>
|
||||
</method>
|
||||
<method name="set_table_version">
|
||||
@ -67,6 +83,7 @@
|
||||
<argument index="0" name="table" type="String" />
|
||||
<argument index="1" name="version" type="int" />
|
||||
<description>
|
||||
Sets the current table version.
|
||||
</description>
|
||||
</method>
|
||||
</methods>
|
||||
|
@ -1,8 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="DatabaseManager" inherits="Object" version="4.4">
|
||||
<brief_description>
|
||||
Database Manager Singleton.
|
||||
</brief_description>
|
||||
<description>
|
||||
Database Manager Singleton.
|
||||
Stores database connections that need to be accessible throughout the application.
|
||||
</description>
|
||||
<tutorials>
|
||||
</tutorials>
|
||||
@ -12,32 +15,38 @@
|
||||
<argument index="0" name="db" type="Database" />
|
||||
<argument index="1" name="set_as_default" type="bool" default="true" />
|
||||
<description>
|
||||
Add a Database. If [code]set_as_default[/code] is true it will be set as default, which means it will be set to the [member ddb] property.
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_database">
|
||||
<return type="Database" />
|
||||
<argument index="0" name="index" type="int" />
|
||||
<description>
|
||||
Returns a Database.
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_database_count">
|
||||
<return type="int" />
|
||||
<description>
|
||||
Returns how many databases are stored in the singleton.
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_databases">
|
||||
<return type="Array" />
|
||||
<description>
|
||||
Returns all Databases.
|
||||
</description>
|
||||
</method>
|
||||
<method name="initialized">
|
||||
<return type="void" />
|
||||
<description>
|
||||
Calls the [code]initialized[/code] signal.
|
||||
</description>
|
||||
</method>
|
||||
<method name="load">
|
||||
<return type="void" />
|
||||
<description>
|
||||
Not implemented currently. Will likely load databases from ProjectSettings.
|
||||
</description>
|
||||
</method>
|
||||
<method name="migrate">
|
||||
@ -46,6 +55,7 @@
|
||||
<argument index="1" name="should_seed" type="bool" />
|
||||
<argument index="2" name="pseed" type="int" />
|
||||
<description>
|
||||
Calls the [member migration] signal.
|
||||
</description>
|
||||
</method>
|
||||
<method name="remove_database">
|
||||
@ -53,31 +63,37 @@
|
||||
<argument index="0" name="index" type="int" />
|
||||
<argument index="1" name="unset_if_default" type="bool" default="true" />
|
||||
<description>
|
||||
Removes a Database.
|
||||
</description>
|
||||
</method>
|
||||
</methods>
|
||||
<members>
|
||||
<member name="ddb" type="Database" setter="set_ddb" getter="get_ddb">
|
||||
The default database.
|
||||
</member>
|
||||
</members>
|
||||
<signals>
|
||||
<signal name="database_added">
|
||||
<argument index="0" name="db" type="Database" />
|
||||
<description>
|
||||
Emitted when a [Database] is added.
|
||||
</description>
|
||||
</signal>
|
||||
<signal name="database_removed">
|
||||
<argument index="0" name="db" type="Database" />
|
||||
<description>
|
||||
Emitted when a [Database] is removed.
|
||||
</description>
|
||||
</signal>
|
||||
<signal name="default_database_changed">
|
||||
<argument index="0" name="db" type="Database" />
|
||||
<description>
|
||||
Emitted when default database is changed.
|
||||
</description>
|
||||
</signal>
|
||||
<signal name="initialized">
|
||||
<description>
|
||||
Can be emitted using the [member initialized] method after the database connections are set up.
|
||||
</description>
|
||||
</signal>
|
||||
<signal name="migration">
|
||||
@ -85,6 +101,7 @@
|
||||
<argument index="1" name="should_seed" type="bool" />
|
||||
<argument index="2" name="pseed" type="int" />
|
||||
<description>
|
||||
Can be emitted using the [member migrate] method when the databse structure needs to be updated (or created).
|
||||
</description>
|
||||
</signal>
|
||||
</signals>
|
||||
|
@ -1,8 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="DatabaseMultiThreaded" inherits="Database" version="4.4">
|
||||
<brief_description>
|
||||
Contains helper methods for multi threaded database systems on the c++ side. Don't use it directly.
|
||||
</brief_description>
|
||||
<description>
|
||||
Contains helper methods for multi threaded database systems on the c++ side. Don't use it directly.
|
||||
</description>
|
||||
<tutorials>
|
||||
</tutorials>
|
||||
|
@ -1,8 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="DatabaseSingleThreaded" inherits="Database" version="4.4">
|
||||
<brief_description>
|
||||
Contains helper methods for single threaded database systems on the c++ side.
|
||||
</brief_description>
|
||||
<description>
|
||||
Contains helper methods for single threaded database systems on the c++ side.
|
||||
</description>
|
||||
<tutorials>
|
||||
</tutorials>
|
||||
|
@ -390,18 +390,36 @@
|
||||
<method name="psph">
|
||||
<return type="QueryBuilder" />
|
||||
<description>
|
||||
Adds a placeholder for prepared statements statement. (psph = Prepared Statement PlaceHolder)
|
||||
Equivalent to:
|
||||
[codeblock]
|
||||
result += "?";
|
||||
[/codeblock]
|
||||
</description>
|
||||
</method>
|
||||
<method name="psphi">
|
||||
<return type="QueryBuilder" />
|
||||
<argument index="0" name="id" type="String" />
|
||||
<description>
|
||||
Adds a placeholder with id for prepared statements statement.
|
||||
Equivalent to:
|
||||
[codeblock]
|
||||
if (id.is_valid_unsigned_integer()):
|
||||
result += "?" + id;
|
||||
else:
|
||||
result += ":" + id;
|
||||
[/codeblock]
|
||||
</description>
|
||||
</method>
|
||||
<method name="psphr">
|
||||
<return type="QueryBuilder" />
|
||||
<argument index="0" name="raw_id" type="String" />
|
||||
<description>
|
||||
Adds a raw placeholder for prepared statements statement.
|
||||
Equivalent to:
|
||||
[codeblock]
|
||||
result += raw_id;
|
||||
[/codeblock]
|
||||
</description>
|
||||
</method>
|
||||
<method name="reset">
|
||||
@ -484,6 +502,14 @@
|
||||
<return type="QueryBuilder" />
|
||||
<argument index="0" name="col" type="String" />
|
||||
<description>
|
||||
Add a prepared statement placeholder parameter to [code]UPDATE[/code] statements.
|
||||
Equivalent to:
|
||||
[codeblock]
|
||||
result += col;
|
||||
result += "=";
|
||||
psph();
|
||||
result += ", ";
|
||||
[/codeblock]
|
||||
</description>
|
||||
</method>
|
||||
<method name="setphi">
|
||||
@ -491,6 +517,14 @@
|
||||
<argument index="0" name="col" type="String" />
|
||||
<argument index="1" name="id" type="String" />
|
||||
<description>
|
||||
Add a prepared statement with id placeholder parameter to [code]UPDATE[/code] statements.
|
||||
Equivalent to:
|
||||
[codeblock]
|
||||
result += col;
|
||||
result += "=";
|
||||
psphi(id);
|
||||
result += ", ";
|
||||
[/codeblock]
|
||||
</description>
|
||||
</method>
|
||||
<method name="setphr">
|
||||
@ -498,6 +532,14 @@
|
||||
<argument index="0" name="col" type="String" />
|
||||
<argument index="1" name="raw_id" type="String" />
|
||||
<description>
|
||||
Add a raw prepared statement placeholder parameter to [code]UPDATE[/code] statements.
|
||||
Equivalent to:
|
||||
[codeblock]
|
||||
result += col;
|
||||
result += "=";
|
||||
psphr(raw_id);
|
||||
result += ", ";
|
||||
[/codeblock]
|
||||
</description>
|
||||
</method>
|
||||
<method name="setpi">
|
||||
@ -611,18 +653,36 @@
|
||||
<method name="valph">
|
||||
<return type="QueryBuilder" />
|
||||
<description>
|
||||
Add a prepared statement placeholder parameter to a [code]VALUES[/code] statement.
|
||||
Equivalent to:
|
||||
[codeblock]
|
||||
psph();
|
||||
result += ", ";
|
||||
[/codeblock]
|
||||
</description>
|
||||
</method>
|
||||
<method name="valphi">
|
||||
<return type="QueryBuilder" />
|
||||
<argument index="0" name="id" type="String" />
|
||||
<description>
|
||||
Add a prepared statement with id placeholder parameter to a [code]VALUES[/code] statement.
|
||||
Equivalent to:
|
||||
[codeblock]
|
||||
psphi(id);
|
||||
result += ", ";
|
||||
[/codeblock]
|
||||
</description>
|
||||
</method>
|
||||
<method name="valphr">
|
||||
<return type="QueryBuilder" />
|
||||
<argument index="0" name="raw_id" type="String" />
|
||||
<description>
|
||||
Add a raw prepared statement placeholder parameter to a [code]VALUES[/code] statement.
|
||||
Equivalent to:
|
||||
[codeblock]
|
||||
psphi(raw_id);
|
||||
result += ", ";
|
||||
[/codeblock]
|
||||
</description>
|
||||
</method>
|
||||
<method name="vals">
|
||||
@ -700,6 +760,14 @@
|
||||
<return type="QueryBuilder" />
|
||||
<argument index="0" name="col" type="String" />
|
||||
<description>
|
||||
Add a prepared statement placeholder parameter to a [code]WHERE[/code] statement. (wpb = where param bool)
|
||||
Equivalent to:
|
||||
[codeblock]
|
||||
result += col;
|
||||
result += "=";
|
||||
psph();
|
||||
result += " ";
|
||||
[/codeblock]
|
||||
</description>
|
||||
</method>
|
||||
<method name="wphi">
|
||||
@ -707,6 +775,14 @@
|
||||
<argument index="0" name="col" type="String" />
|
||||
<argument index="1" name="id" type="String" />
|
||||
<description>
|
||||
Add a prepared statement with id placeholder parameter to a [code]WHERE[/code] statement. (wpb = where param bool)
|
||||
Equivalent to:
|
||||
[codeblock]
|
||||
result += col;
|
||||
result += "=";
|
||||
psphi(id);
|
||||
result += " ";
|
||||
[/codeblock]
|
||||
</description>
|
||||
</method>
|
||||
<method name="wphr">
|
||||
@ -714,6 +790,14 @@
|
||||
<argument index="0" name="col" type="String" />
|
||||
<argument index="1" name="raw_id" type="String" />
|
||||
<description>
|
||||
Add a raw prepared statement placeholder parameter to a [code]WHERE[/code] statement. (wpb = where param bool)
|
||||
Equivalent to:
|
||||
[codeblock]
|
||||
result += col;
|
||||
result += "=";
|
||||
psphr(raw_id);
|
||||
result += " ";
|
||||
[/codeblock]
|
||||
</description>
|
||||
</method>
|
||||
<method name="wpi">
|
||||
|
@ -1,8 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="QueryResult" inherits="Reference" version="4.4">
|
||||
<brief_description>
|
||||
Read the result from a query that were run on a [Database].
|
||||
</brief_description>
|
||||
<description>
|
||||
Read the result from a query that were run on a [Database].
|
||||
</description>
|
||||
<tutorials>
|
||||
</tutorials>
|
||||
@ -11,51 +13,60 @@
|
||||
<return type="String" />
|
||||
<argument index="0" name="index" type="int" />
|
||||
<description>
|
||||
Gets a [String] value from the index-th cell.
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_cell_bool">
|
||||
<return type="bool" />
|
||||
<argument index="0" name="index" type="int" />
|
||||
<description>
|
||||
Gets a bool value from the index-th cell.
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_cell_double">
|
||||
<return type="float" />
|
||||
<argument index="0" name="index" type="int" />
|
||||
<description>
|
||||
Gets a double value from the index-th cell.
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_cell_float">
|
||||
<return type="float" />
|
||||
<argument index="0" name="index" type="int" />
|
||||
<description>
|
||||
Gets a float value from the index-th cell.
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_cell_int">
|
||||
<return type="int" />
|
||||
<argument index="0" name="index" type="int" />
|
||||
<description>
|
||||
Gets a int value from the index-th cell.
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_error_message">
|
||||
<return type="String" />
|
||||
<description>
|
||||
Returns the current error message (if any).
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_last_insert_rowid">
|
||||
<return type="int" />
|
||||
<description>
|
||||
Returns the last inserted row's id. On some database backends this needs to be requested in the query to be available.
|
||||
</description>
|
||||
</method>
|
||||
<method name="is_cell_null">
|
||||
<return type="bool" />
|
||||
<argument index="0" name="index" type="int" />
|
||||
<description>
|
||||
Is the given cell null.
|
||||
</description>
|
||||
</method>
|
||||
<method name="next_row">
|
||||
<return type="bool" />
|
||||
<description>
|
||||
Read the next row. Returns true if success, false if no more rows available.
|
||||
</description>
|
||||
</method>
|
||||
</methods>
|
||||
|
@ -204,6 +204,7 @@
|
||||
<method name="reset">
|
||||
<return type="void" />
|
||||
<description>
|
||||
Resets the result.
|
||||
</description>
|
||||
</method>
|
||||
<method name="run">
|
||||
|
Loading…
Reference in New Issue
Block a user