Files
Paradise/datum/db_query.html

26 lines
11 KiB
HTML
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><base href="../"><link rel="stylesheet" href="dmdoc.css"><title>/datum/db_query - Space Station 13</title></head><body><header><a href="index.html">Space Station 13</a> - <a href="index.html#modules">Modules</a> - <a href="index.html#types">Types</a><a href="datum/db_query.html#var">Var Details</a> - <a href="datum/db_query.html#proc">Proc Details</a></header><main><h1>db_query <aside>/<a href="datum.html">datum</a>/<a href="datum/db_query.html">db_query</a></aside> <a href="https://github.com/ParadiseSS13/Paradise/blob/8a8a00a2a9bec485351e5f219982b7315d3504fa/code/controllers/subsystem/SSdbcore.dm#L538"><img src="git.png" width="16" height="16" title="code/controllers/subsystem/SSdbcore.dm 538"></a></h1><p>Datum based handler for all database queries</p>
<p>Holds information regarding inputs, status, and outputs</p><table class="summary" cellspacing="0"><tr><td colspan="2"><h2>Vars</h2></td></tr><tr><th><a href="datum/db_query.html#var/affected">affected</a></th><td>How many rows were affected by the query</td></tr><tr><th><a href="datum/db_query.html#var/arguments">arguments</a></th><td>An associative list of parameters to be substituted into the statement</td></tr><tr><th><a href="datum/db_query.html#var/connection">connection</a></th><td>The connection being used with this query</td></tr><tr><th><a href="datum/db_query.html#var/in_progress">in_progress</a></th><td>Is the query currently in progress</td></tr><tr><th><a href="datum/db_query.html#var/item">item</a></th><td>List of data values populated by NextRow()</td></tr><tr><th><a href="datum/db_query.html#var/last_activity">last_activity</a></th><td>What was our last activity</td></tr><tr><th><a href="datum/db_query.html#var/last_activity_time">last_activity_time</a></th><td>When was our last activity</td></tr><tr><th><a href="datum/db_query.html#var/last_error">last_error</a></th><td>What was our last error, if any</td></tr><tr><th><a href="datum/db_query.html#var/last_insert_id">last_insert_id</a></th><td>ID of the last inserted row</td></tr><tr><th><a href="datum/db_query.html#var/next_row_to_take">next_row_to_take</a></th><td>Counter of the next row to take</td></tr><tr><th><a href="datum/db_query.html#var/query_id">query_id</a></th><td>What is the query ID?</td></tr><tr><th><a href="datum/db_query.html#var/rows">rows</a></th><td>List of all rows returned</td></tr><tr><th><a href="datum/db_query.html#var/sql">sql</a></th><td>The SQL statement being executed with :parameter placeholders</td></tr><tr><td colspan="2"><h2>Procs</h2></td></tr><tr><th><a href="datum/db_query.html#proc/Activity">Activity</a></th><td>Activity Update Handler</td></tr><tr><th><a href="datum/db_query.html#proc/Execute">Execute</a></th><td>Main Execution Handler</td></tr><tr><th><a href="datum/db_query.html#proc/NextRow">NextRow</a></th><td>Proc to get the next row in a DB query</td></tr><tr><th><a href="datum/db_query.html#proc/run_query">run_query</a></th><td>Actual Query Runner</td></tr><tr><th><a href="datum/db_query.html#proc/warn_execute">warn_execute</a></th><td>Wrapped for warning on execution</td></tr></table><h2 id="var">Var Details</h2><h3 id="var/affected"><aside class="declaration">var </aside>affected <a href="https://github.com/ParadiseSS13/Paradise/blob/8a8a00a2a9bec485351e5f219982b7315d3504fa/code/controllers/subsystem/SSdbcore.dm#L565"><img src="git.png" width="16" height="16" title="code/controllers/subsystem/SSdbcore.dm 565"></a></h3><p>How many rows were affected by the query</p><h3 id="var/arguments"><aside class="declaration">var </aside>arguments <a href="https://github.com/ParadiseSS13/Paradise/blob/8a8a00a2a9bec485351e5f219982b7315d3504fa/code/controllers/subsystem/SSdbcore.dm#L545"><img src="git.png" width="16" height="16" title="code/controllers/subsystem/SSdbcore.dm 545"></a></h3><p>An associative list of parameters to be substituted into the statement</p><h3 id="var/connection"><aside class="declaration">var </aside>connection <a href="https://github.com/ParadiseSS13/Paradise/blob/8a8a00a2a9bec485351e5f219982b7315d3504fa/code/controllers/subsystem/SSdbcore.dm#L541"><img src="git.png" width="16" height="16" title="code/controllers/subsystem/SSdbcore.dm 541"></a></h3><p>The connection being used with this query</p><h3 id="var/in_progress"><aside class="declaration">var </aside>in_progress <a href="https://github.com/ParadiseSS13/Paradise/blob/8a8a00a2a9bec485351e5f219982b7315d3504fa/code/controllers/subsystem/SSdbcore.dm#L549"><img src="git.png" width="16" height="16" title="code/controllers/subsystem/SSdbcore.dm 549"></a></h3><p>Is the query currently in progress</p><h3 id="var/item"><aside class="declaration">var </aside>item <aside> /list</aside> <a href="https://github.com/ParadiseSS13/Paradise/blob/8a8a00a2a9bec485351e5f219982b7315d3504fa/code/controllers/subsystem/SSdbcore.dm#L569"><img src="git.png" width="16" height="16" title="code/controllers/subsystem/SSdbcore.dm 569"></a></h3><p>List of data values populated by NextRow()</p><h3 id="var/last_activity"><aside class="declaration">var </aside>last_activity <a href="https://github.com/ParadiseSS13/Paradise/blob/8a8a00a2a9bec485351e5f219982b7315d3504fa/code/controllers/subsystem/SSdbcore.dm#L555"><img src="git.png" width="16" height="16" title="code/controllers/subsystem/SSdbcore.dm 555"></a></h3><p>What was our last activity</p><h3 id="var/last_activity_time"><aside class="declaration">var </aside>last_activity_time <a href="https://github.com/ParadiseSS13/Paradise/blob/8a8a00a2a9bec485351e5f219982b7315d3504fa/code/controllers/subsystem/SSdbcore.dm#L557"><img src="git.png" width="16" height="16" title="code/controllers/subsystem/SSdbcore.dm 557"></a></h3><p>When was our last activity</p><h3 id="var/last_error"><aside class="declaration">var </aside>last_error <a href="https://github.com/ParadiseSS13/Paradise/blob/8a8a00a2a9bec485351e5f219982b7315d3504fa/code/controllers/subsystem/SSdbcore.dm#L553"><img src="git.png" width="16" height="16" title="code/controllers/subsystem/SSdbcore.dm 553"></a></h3><p>What was our last error, if any</p><h3 id="var/last_insert_id"><aside class="declaration">var </aside>last_insert_id <a href="https://github.com/ParadiseSS13/Paradise/blob/8a8a00a2a9bec485351e5f219982b7315d3504fa/code/controllers/subsystem/SSdbcore.dm#L567"><img src="git.png" width="16" height="16" title="code/controllers/subsystem/SSdbcore.dm 567"></a></h3><p>ID of the last inserted row</p><h3 id="var/next_row_to_take"><aside class="declaration">var </aside>next_row_to_take <a href="https://github.com/ParadiseSS13/Paradise/blob/8a8a00a2a9bec485351e5f219982b7315d3504fa/code/controllers/subsystem/SSdbcore.dm#L563"><img src="git.png" width="16" height="16" title="code/controllers/subsystem/SSdbcore.dm 563"></a></h3><p>Counter of the next row to take</p><h3 id="var/query_id"><aside class="declaration">var </aside>query_id <a href="https://github.com/ParadiseSS13/Paradise/blob/8a8a00a2a9bec485351e5f219982b7315d3504fa/code/controllers/subsystem/SSdbcore.dm#L551"><img src="git.png" width="16" height="16" title="code/controllers/subsystem/SSdbcore.dm 551"></a></h3><p>What is the query ID?</p><h3 id="var/rows"><aside class="declaration">var </aside>rows <aside> /list/list</aside> <a href="https://github.com/ParadiseSS13/Paradise/blob/8a8a00a2a9bec485351e5f219982b7315d3504fa/code/controllers/subsystem/SSdbcore.dm#L561"><img src="git.png" width="16" height="16" title="code/controllers/subsystem/SSdbcore.dm 561"></a></h3><p>List of all rows returned</p><h3 id="var/sql"><aside class="declaration">var </aside>sql <a href="https://github.com/ParadiseSS13/Paradise/blob/8a8a00a2a9bec485351e5f219982b7315d3504fa/code/controllers/subsystem/SSdbcore.dm#L543"><img src="git.png" width="16" height="16" title="code/controllers/subsystem/SSdbcore.dm 543"></a></h3><p>The SQL statement being executed with :parameter placeholders</p><h2 id="proc">Proc Details</h2><h3 id="proc/Activity"><aside class="declaration">proc </aside>Activity<aside>(activity) <a href="https://github.com/ParadiseSS13/Paradise/blob/8a8a00a2a9bec485351e5f219982b7315d3504fa/code/controllers/subsystem/SSdbcore.dm#L358"><img src="git.png" width="16" height="16" title="code/controllers/subsystem/SSdbcore.dm 358"></a></aside></h3><p>Activity Update Handler</p>
<p>Sets the last activity text to the argument input, as well as updating the activity time</p>
<p>Arguments:</p>
<ul>
<li>activity - Last activity text</li>
</ul><h3 id="proc/Execute"><aside class="declaration">proc </aside>Execute<aside>(async, log_error) <a href="https://github.com/ParadiseSS13/Paradise/blob/8a8a00a2a9bec485351e5f219982b7315d3504fa/code/controllers/subsystem/SSdbcore.dm#L390"><img src="git.png" width="16" height="16" title="code/controllers/subsystem/SSdbcore.dm 390"></a></aside></h3><p>Main Execution Handler</p>
<p>Invoked by [warn_execute()]
This handles query error logging, as well as invoking the actual runner
Arguments:</p>
<ul>
<li>async - Are we running this query asynchronously</li>
<li>log_error - Do we want to log errors this creates? Disable this if you are running sensitive queries where you dont want errors logged in plain text (EG: Auth token stuff)</li>
</ul><h3 id="proc/NextRow"><aside class="declaration">proc </aside>NextRow<aside>() <a href="https://github.com/ParadiseSS13/Paradise/blob/8a8a00a2a9bec485351e5f219982b7315d3504fa/code/controllers/subsystem/SSdbcore.dm#L464"><img src="git.png" width="16" height="16" title="code/controllers/subsystem/SSdbcore.dm 464"></a></aside></h3><p>Proc to get the next row in a DB query</p>
<p>Cycles <code>item</code> to the next row in the DB query, if multiple were fetched</p><h3 id="proc/run_query"><aside class="declaration">proc </aside>run_query<aside>(async) <a href="https://github.com/ParadiseSS13/Paradise/blob/8a8a00a2a9bec485351e5f219982b7315d3504fa/code/controllers/subsystem/SSdbcore.dm#L422"><img src="git.png" width="16" height="16" title="code/controllers/subsystem/SSdbcore.dm 422"></a></aside></h3><p>Actual Query Runner</p>
<p>This does the main query with the database and the rust calls themselves</p>
<p>Arguments:</p>
<ul>
<li>async - Are we running this query asynchronously</li>
</ul><h3 id="proc/warn_execute"><aside class="declaration">proc </aside>warn_execute<aside>(async, log_error) <a href="https://github.com/ParadiseSS13/Paradise/blob/8a8a00a2a9bec485351e5f219982b7315d3504fa/code/controllers/subsystem/SSdbcore.dm#L371"><img src="git.png" width="16" height="16" title="code/controllers/subsystem/SSdbcore.dm 371"></a></aside></h3><p>Wrapped for warning on execution</p>
<p>You should use this proc when running the SQL statement. It will auto inform the user and the online admins if a query fails</p>
<p>Arguments:</p>
<ul>
<li>async - Are we running this query asynchronously</li>
<li>log_error - Do we want to log errors this creates? Disable this if you are running sensitive queries where you dont want errors logged in plain text (EG: Auth token stuff)</li>
</ul></main><footer>paradise.dme <a href="https://github.com/ParadiseSS13/Paradise/tree/8a8a00a2a9bec485351e5f219982b7315d3504fa">8a8a00a</a> (master) — <a href="https://github.com/SpaceManiac/SpacemanDMM/blob/master/crates/dmdoc/README.md">dmdoc 1.11.0</a></footer></body></html>