pandemonium_engine/modules/database/doc_classes/TableBuilder.xml

297 lines
8.3 KiB
XML
Raw Normal View History

2022-08-21 00:40:49 +02:00
<?xml version="1.0" encoding="UTF-8" ?>
2024-04-26 17:32:25 +02:00
<class name="TableBuilder" inherits="Reference" version="4.4">
2022-08-21 00:40:49 +02:00
<brief_description>
2022-12-27 21:43:11 +01:00
A class that helps you with building and running database backend specific sql for creating / altering / deleting tables.
2022-08-21 00:40:49 +02:00
</brief_description>
<description>
2022-12-27 21:43:11 +01:00
A class that helps you with building and running database backend specific sql for creating / altering / deleting tables.
It contains helper methods that lets you run the finished query directly See [method run] and [method run_query].
You should not allocate this directly, instead get it from you active database connection, like:
[codeblock]
var conn : DatabaseConnection = DatabaseManager.ddb.get_connection()
var tb : TableBuilder = conn.get_table_builder()
[/codeblock]
2022-08-21 00:40:49 +02:00
</description>
<tutorials>
</tutorials>
<methods>
<method name="auto_increment">
<return type="TableBuilder" />
<description>
2022-12-27 21:43:11 +01:00
Adds an [code]AUTO_INCREMENT[/code] statement.
Equivalent to:
[codeblock]
result += "AUTO_INCREMENT "
[/codeblock]
2022-08-21 00:40:49 +02:00
</description>
</method>
<method name="ccreate_table">
<return type="TableBuilder" />
<description>
2022-12-27 21:43:11 +01:00
Closes a [code]CREATE TABLE[/code] statement.
Equivalent to:
[codeblock]
result += ");"
[/codeblock]
2022-08-21 00:40:49 +02:00
</description>
</method>
<method name="cdrop_table">
<return type="TableBuilder" />
<description>
2022-12-27 21:43:11 +01:00
Closes a [code]DROP TABLE[/code] statement.
Equivalent to:
[codeblock]
result += ";"
[/codeblock]
2022-08-21 00:40:49 +02:00
</description>
</method>
<method name="create_table">
<return type="TableBuilder" />
<argument index="0" name="value" type="String" />
<description>
2022-12-27 21:43:11 +01:00
Adds a [code]CREATE TABLE[/code] statement.
Equivalent to:
[codeblock]
result += "CREATE TABLE " + name + " ( "
[/codeblock]
2022-08-21 00:40:49 +02:00
</description>
</method>
<method name="date">
<return type="TableBuilder" />
<argument index="0" name="name" type="String" />
<description>
2022-12-27 21:43:11 +01:00
Adds a [code]DATE[/code] field statement.
Equivalent to:
[codeblock]
result += name + " DATE "
[/codeblock]
2022-08-21 00:40:49 +02:00
</description>
</method>
<method name="defval">
<return type="TableBuilder" />
<argument index="0" name="val" type="String" />
<description>
2022-12-27 21:43:11 +01:00
Adds a [code]DEFAULT[/code] statement.
Equivalent to:
[codeblock]
result += "DEFAULT '" + val + "'"
[/codeblock]
2022-08-21 00:40:49 +02:00
</description>
</method>
<method name="drop_table">
<return type="TableBuilder" />
<argument index="0" name="name" type="String" default="&quot;&quot;" />
<description>
2022-12-27 21:43:11 +01:00
Adds a [code]DROP TABLE[/code] statement.
Equivalent to:
[codeblock]
result += "DROP TABLE "
[/codeblock]
2022-08-21 00:40:49 +02:00
</description>
</method>
<method name="drop_table_if_exists">
<return type="TableBuilder" />
<argument index="0" name="name" type="String" default="&quot;&quot;" />
<description>
2022-12-27 21:43:11 +01:00
Adds a [code]DROP TABLE IF EXISTS[/code] statement.
Equivalent to:
[codeblock]
result += "DROP TABLE IF EXISTS "
[/codeblock]
2022-08-21 00:40:49 +02:00
</description>
</method>
<method name="foreign_key">
<return type="TableBuilder" />
<argument index="0" name="name" type="String" />
<description>
2022-12-27 21:43:11 +01:00
Adds a [code]FOREIGN KEY[/code] statement.
Equivalent to:
[codeblock]
result += "FOREIGN KEY (" + name + ") "
[/codeblock]
2022-08-21 00:40:49 +02:00
</description>
</method>
<method name="integer">
<return type="TableBuilder" />
<argument index="0" name="name" type="String" />
2022-12-22 19:28:17 +01:00
<argument index="1" name="length" type="int" default="-1" />
2022-08-21 00:40:49 +02:00
<description>
2022-12-27 21:43:11 +01:00
Adds an [code]INTEGER[/code] field statement.
Equivalent to:
[codeblock]
result += name + " INTEGER ";
if (length != -1):
result += "(" + str(length) + ") "
[/codeblock]
2022-08-21 00:40:49 +02:00
</description>
</method>
<method name="next_row">
<return type="TableBuilder" />
<description>
2022-12-27 21:43:11 +01:00
Go the the next row (field) in the current sql statement.
Equivalent to:
[codeblock]
result += ", "
[/codeblock]
2022-08-21 00:40:49 +02:00
</description>
</method>
<method name="not_null">
<return type="TableBuilder" />
<description>
2022-12-27 21:43:11 +01:00
Adds a [code]NOT NULL[/code] statement.
Equivalent to:
[codeblock]
result += "NOT NULL "
[/codeblock]
2022-08-21 00:40:49 +02:00
</description>
</method>
<method name="null">
<return type="TableBuilder" />
<description>
2022-12-27 21:43:11 +01:00
Adds a [code]NULL[/code] statement.
Equivalent to:
[codeblock]
result += "NULL "
[/codeblock]
2022-08-21 00:40:49 +02:00
</description>
</method>
<method name="primary_key">
<return type="TableBuilder" />
<argument index="0" name="name" type="String" default="&quot;&quot;" />
<description>
2022-12-27 21:43:11 +01:00
Adds a [code]PRIMARY KEY[/code] statement.
Equivalent to:
[codeblock]
result += "PRIMARY KEY (" + name + ") "
[/codeblock]
2022-08-21 00:40:49 +02:00
</description>
</method>
<method name="real_double">
<return type="TableBuilder" />
<argument index="0" name="name" type="String" />
<argument index="1" name="size" type="int" default="-1" />
<argument index="2" name="d" type="int" default="-1" />
<description>
2022-12-27 21:43:11 +01:00
Adds an [code]DOUBLE[/code] field statement.
Equivalent to:
[codeblock]
result += name + " DOUBLE "
[/codeblock]
2022-08-21 00:40:49 +02:00
</description>
</method>
<method name="real_float">
<return type="TableBuilder" />
<argument index="0" name="name" type="String" />
<argument index="1" name="size" type="int" default="-1" />
<argument index="2" name="d" type="int" default="-1" />
<description>
2022-12-27 21:43:11 +01:00
Adds an [code]FLOAT[/code] field statement.
Equivalent to:
[codeblock]
result += name + " FLOAT "
[/codeblock]
2022-08-21 00:40:49 +02:00
</description>
</method>
<method name="references">
<return type="TableBuilder" />
<argument index="0" name="table" type="String" />
<argument index="1" name="name" type="String" />
<description>
2023-01-14 13:38:58 +01:00
result += "REFERENCES " + table + " (" + name + ") ";
2022-08-21 00:40:49 +02:00
</description>
</method>
2024-04-27 21:08:04 +02:00
<method name="reset">
<return type="void" />
<description>
Resets the result.
2024-04-27 21:08:04 +02:00
</description>
</method>
2022-08-21 00:40:49 +02:00
<method name="run">
<return type="QueryResult" />
<description>
2022-12-27 21:43:11 +01:00
Run the query currently stored in the result property.
Use this if your query returns values from the database (an you want to read them).
2022-08-21 00:40:49 +02:00
</description>
</method>
<method name="run_query">
<return type="void" />
<description>
2022-12-27 21:43:11 +01:00
Run the query currently stored in the result property.
Use this if your query doesn't return values from the database (or you don't want to read them if it does).
2022-08-21 00:40:49 +02:00
</description>
</method>
<method name="small_integer">
<return type="TableBuilder" />
<argument index="0" name="name" type="String" />
<argument index="1" name="length" type="int" default="-1" />
<description>
2022-12-27 21:43:11 +01:00
Adds a [code]SMALL INTEGER[/code] field statement.
Equivalent to:
[codeblock]
result += name + " INTEGER("
if (length == -1):
result += "6"
else:
result += itos(length)
2023-01-14 13:38:58 +01:00
2022-12-27 21:43:11 +01:00
result += ") "
[/codeblock]
2022-08-21 00:40:49 +02:00
</description>
</method>
<method name="text">
<return type="TableBuilder" />
<argument index="0" name="name" type="String" />
<description>
2022-12-27 21:43:11 +01:00
Adds a [code]TEXT[/code] field statement.
Equivalent to:
[codeblock]
result += name + " TEXT "
[/codeblock]
2022-08-21 00:40:49 +02:00
</description>
</method>
<method name="tiny_integer">
<return type="TableBuilder" />
<argument index="0" name="name" type="String" />
<argument index="1" name="length" type="int" default="-1" />
<description>
2022-12-27 21:43:11 +01:00
Adds a [code]TINY INTEGER[/code] field statement.
Equivalent to:
[codeblock]
result += name + " INTEGER("
if (length == -1):
result += "4"
else:
result += itos(length)
result += ") "
[/codeblock]
2022-08-21 00:40:49 +02:00
</description>
</method>
<method name="varchar">
<return type="TableBuilder" />
<argument index="0" name="name" type="String" />
<argument index="1" name="length" type="int" default="-1" />
<description>
2022-12-27 21:43:11 +01:00
Adds a [code]VARCHAR[/code] field statement.
Equivalent to:
[codeblock]
result += name + " VARCHAR ";
if (length != -1):
result += "(" + str(length) + ") "
[/codeblock]
2022-08-21 00:40:49 +02:00
</description>
</method>
</methods>
<members>
<member name="result" type="String" setter="set_result" getter="get_result" default="&quot;&quot;">
2022-12-27 21:43:11 +01:00
The current (resulting) sql statement.
2022-08-21 00:40:49 +02:00
</member>
</members>
<constants>
</constants>
</class>