-
Notifications
You must be signed in to change notification settings - Fork 0
/
a_sampdb.inc
130 lines (112 loc) · 9.35 KB
/
a_sampdb.inc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
// SA-MP Native SQLite Database Functions
//
// (c) Copyright 2015, SA-MP Team
//
#if defined _sampdb_included
#endinput
#endif
#define _sampdb_included
#pragma library sampdb
/// <summary>This function is used to open a connection to a SQLite database, which is inside the <b><c>/scriptfiles</c></b> folder.</summary>
/// <param name="name">File name of the database</param>
/// <remarks>Return type for this function has changed since version <b>0.3.7 R2</b>.</remarks>
/// <remarks>
/// It will create a new SQLite database, if there is no SQLite database with the same file name available.<p/>
/// <b>Close</b> your database connection with <a href="#db_close">db_close</a>!
/// </remarks>
/// <returns>Returns index (starting at <b><c>1</c></b>) of the database connection .</returns>
native DB:db_open(name[]);
/// <summary>Closes an SQLite database that was opened with <a href="#db_open">db_open</a>.</summary>
/// <param name="db">The handle of the database connection to close (returned by <a href="#db_open">db_open</a>)</param>
/// <remarks>Using an <b>invalid handle</b> will crash your server! Get a <b>valid handle</b> by using <a href="#db_open">db_open</a>. But it's protected against <b><c>NULL</c></b> references</remarks>
/// <returns>
/// <b><c>1</c></b>: The function executed successfully.<p/>
/// <b><c>0</c></b>: The function failed to execute. May mean that the database handle specified is not open.
/// </returns>
native db_close(DB:db);
/// <summary>This function is used to execute an SQL query on an opened SQLite database.</summary>
/// <param name="db">The database handle to query</param>
/// <param name="query">The query to execute</param>
/// <remarks>Return type for this function has changed since version <b>0.3.7 R2</b>.</remarks>
/// <remarks><b>Always</b> free the result by using <a href="#db_free_result">db_free_result</a>!</remarks>
/// <returns>The query result index (<b>starting at 1</b>).</returns>
native DBResult:db_query(DB:db, query[]);
/// <summary>Frees result memory allocated from <a href="#db_query">db_query</a>.</summary>
/// <param name="dbresult">The result to free</param>
/// <returns>If <b><c>DBResult:dbhandle</c></b> is a valid handle, it returns <b><c>1</c></b>, otherwise <b><c>0</c></b> if <b><c>DBResult:dbhandle</c></b> is a <b><c>NULL</c></b> reference.</returns>
native db_free_result(DBResult:dbresult);
/// <summary>Returns the number of rows from a <a href="#db_query">db_query</a>.</summary>
/// <param name="dbresult">The result of <a href="#db_query">db_query</a></param>
/// <remarks>Using an <b>invalid handle</b> will crash your server! Get a <b>valid handle</b> by using <a href="#db_open">db_open</a>. But it's protected against <b><c>NULL</c></b> references</remarks>
/// <returns>The number of rows in the result.</returns>
native db_num_rows(DBResult:dbresult);
/// <summary>Moves to the next row of the result allocated from <a href="#db_query">db_query</a>.</summary>
/// <param name="dbresult">The result of <a href="#db_query">db_query</a></param>
/// <remarks>Using an <b>invalid handle</b> will crash your server! Get a <b>valid handle</b> by using <a href="#db_open">db_open</a>. But it's protected against <b><c>NULL</c></b> references</remarks>
/// <returns>Returns <b><c>1</c></b> on success, otherwise <b><c>0</c></b> if <b><c>DBResult:dbresult</c></b> is a <b><c>NULL</c></b> reference or the last row is reached.</returns>
native db_next_row(DBResult:dbresult);
/// <summary>Get the number of fields in a result.</summary>
/// <param name="dbresult">The result of <a href="#db_query">db_query</a></param>
/// <remarks>Using an <b>invalid handle</b> will crash your server! Get a <b>valid handle</b> by using <a href="#db_open">db_open</a>. But it's protected against <b><c>NULL</c></b> references</remarks>
/// <returns>The number of fields in the result.</returns>
native db_num_fields(DBResult:dbresult);
/// <summary>Returns the name of a field at a particular index.</summary>
/// <param name="dbresult">The result to get the data from; returned by <a href="#db_query">db_query</a></param>
/// <param name="field">The index of the field to get the name of</param>
/// <param name="result">The result</param>
/// <param name="maxlength">The max length of the field</param>
/// <remarks>Using an <b>invalid handle</b> will crash your server! Get a <b>valid handle</b> by using <a href="#db_open">db_open</a>. But it's protected against <b><c>NULL</c></b> references</remarks>
/// <returns>Returns <b><c>1</c></b>, if the function was successful, otherwise <b><c>0</c></b> if <b><c>DBResult:dbresult</c></b> is a <b><c>NULL</c></b> reference or the column index not available.</returns>
native db_field_name(DBResult:dbresult, field, result[], maxlength);
/// <summary>Get the content of a field from <a href="#db_query">db_query</a>.</summary>
/// <param name="dbresult">The result to get the data from</param>
/// <param name="field">The field to get the data from</param>
/// <param name="result">The result</param>
/// <param name="maxlength">The max length of the field</param>
/// <remarks>Using an <b>invalid handle</b> will crash your server! Get a <b>valid handle</b> by using <a href="#db_open">db_open</a>. But it's protected against <b><c>NULL</c></b> references</remarks>
/// <returns>Returns <b><c>1</c></b> if successful, otherwise <b><c>0</c></b> if <b><c>DBResult:dbresult</c></b> is a <b><c>NULL</c></b> reference or the column index not available.</returns>
native db_get_field(DBResult:dbresult, field, result[], maxlength);
/// <summary>Get the content of a field as an integer from <a href="#db_query">db_query</a>.</summary>
/// <param name="result">The result to get the data from</param>
/// <param name="field">The field to get the data from (optional=<b><c>0</c></b>)</param>
/// <remarks>Using an <b>invalid handle</b> will crash your server! Get a <b>valid handle</b> by using <a href="#db_open">db_open</a>. But it's protected against <b><c>NULL</c></b> references</remarks>
/// <returns>Retrieved value as integer (number).</returns>
native db_get_field_int(DBResult:result, field = 0);
/// <summary>Get the content of a field as a float from db_query.</summary>
/// <param name="dbresult">The result to get the data from</param>
/// <param name="field">The field to get the data from (optional=<b><c>0</c></b>)</param>
/// <remarks>Using an <b>invalid handle</b> will crash your server! Get a <b>valid handle</b> by using <a href="#db_open">db_open</a>. But it's protected against <b><c>NULL</c></b> references</remarks>
/// <returns>Retrieved value as floating point number.</returns>
native Float:db_get_field_float(DBResult:dbresult, field = 0);
/// <summary>Get the contents of field with specified name.</summary>
/// <param name="dbresult">The result to get the data from</param>
/// <param name="field">The fieldname to get the data from</param>
/// <param name="result">The result</param>
/// <param name="maxlength">The max length of the field</param>
/// <remarks>Using an <b>invalid handle</b> will crash your server! Get a <b>valid handle</b> by using <a href="#db_open">db_open</a>. But it's protected against <b><c>NULL</c></b> references</remarks>
/// <returns>Returns <b><c>1</c></b> if successful, otherwise <b><c>0</c></b> if <b><c>DBResult:dbresult</c></b> is a <b><c>NULL</c></b> reference or the column index not available.</returns>
native db_get_field_assoc(DBResult:dbresult, const field[], result[], maxlength);
/// <summary>Get the contents of field as an integer with specified name.</summary>
/// <param name="dbresult">The result to get the data from</param>
/// <param name="field">The fieldname to get the data from</param>
/// <remarks>Using an <b>invalid handle</b> will crash your server! Get a <b>valid handle</b> by using <a href="#db_open">db_open</a>. But it's protected against <b><c>NULL</c></b> references</remarks>
/// <returns>Retrieved value as integer (number).</returns>
native db_get_field_assoc_int(DBResult:dbresult, const field[]);
/// <summary>Get the contents of field as a float with specified name.</summary>
/// <param name="dbresult">The result to get the data from</param>
/// <param name="field">The fieldname to get the data from</param>
/// <remarks>Using an <b>invalid handle</b> will crash your server! Get a <b>valid handle</b> by using <a href="#db_open">db_open</a>. But it's protected against <b><c>NULL</c></b> references</remarks>
/// <returns>Retrieved value as floating point number.</returns>
native Float:db_get_field_assoc_float(DBResult:dbresult, const field[]);
/// <summary>Get memory handle for an SQLite database that was opened with <a href="#db_open">db_open</a>.</summary>
/// <param name="db">The index of the database connection (returned by <a href="#db_open">db_open</a>)</param>
/// <remarks>This function was added in <b>SA-MP 0.3.7 R1</b> and will not work in earlier versions!</remarks>
/// <returns>Returns the memory handle for a specified database.</returns>
native db_get_mem_handle(DB:db);
/// <summary>Get <b>memory handle</b> for an SQLite query that was executed with <a href="#db_query">db_query</a>.</summary>
/// <param name="dbresult">The index of the query (returned by <a href="#db_query">db_query</a>)</param>
/// <remarks>This function was added in <b>SA-MP 0.3.7 R1</b> and will not work in earlier versions!</remarks>
/// <returns>Returns the memory handle for a specified query.</returns>
native db_get_result_mem_handle(DBResult:dbresult);
native db_debug_openfiles();
native db_debug_openresults();