NWNX:EE  8193.37.14
nwnx_sql.nss
Go to the documentation of this file.
1 
6 const string NWNX_SQL = "NWNX_SQL";
7 
12 int NWNX_SQL_PrepareQuery(string query);
13 
17 
21 int NWNX_SQL_ExecuteQuery(string query);
22 
26 
31 
35 string NWNX_SQL_ReadDataInActiveRow(int column = 0);
36 
40 void NWNX_SQL_PreparedInt(int position, int value);
41 
45 void NWNX_SQL_PreparedString(int position, string value);
46 
50 void NWNX_SQL_PreparedFloat(int position, float value);
51 
55 void NWNX_SQL_PreparedObjectId(int position, object value);
56 
61 void NWNX_SQL_PreparedObjectFull(int position, object value, int base64 = TRUE);
62 
65 void NWNX_SQL_PreparedNULL(int position);
66 
71 void NWNX_SQL_PreparedJson(int position, json value);
72 
87 object NWNX_SQL_ReadFullObjectInActiveRow(int column = 0, object owner = OBJECT_INVALID, float x = 0.0, float y = 0.0, float z = 0.0, int base64 = TRUE);
88 
93 
98 
102 
104 string NWNX_SQL_GetLastError();
105 
109 
113 
115 
116 int NWNX_SQL_PrepareQuery(string query)
117 {
118  NWNXPushString(query);
119  NWNXCall(NWNX_SQL, "PrepareQuery");
120  return NWNXPopInt();
121 }
122 
124 {
125  NWNXCall(NWNX_SQL, "ExecutePreparedQuery");
126  return NWNXPopInt();
127 }
128 
129 int NWNX_SQL_ExecuteQuery(string query)
130 {
131  // Note: the implementation might change as support for more SQL targets arrives.
132  if (NWNX_SQL_PrepareQuery(query))
133  {
134  int ret = NWNX_SQL_ExecutePreparedQuery();
136  return ret;
137  }
138 
139  return FALSE;
140 }
141 
143 {
144  NWNXCall(NWNX_SQL, "ReadyToReadNextRow");
145  return NWNXPopInt();
146 }
147 
149 {
150  NWNXCall(NWNX_SQL, "ReadNextRow");
151 }
152 
153 string NWNX_SQL_ReadDataInActiveRow(int column = 0)
154 {
155  NWNXPushInt(column);
156  NWNXCall(NWNX_SQL, "ReadDataInActiveRow");
157  return NWNXPopString();
158 }
159 
160 
161 void NWNX_SQL_PreparedInt(int position, int value)
162 {
163  NWNXPushInt(value);
164  NWNXPushInt(position);
165  NWNXCall(NWNX_SQL, "PreparedInt");
166 }
167 void NWNX_SQL_PreparedString(int position, string value)
168 {
169  NWNXPushString(value);
170  NWNXPushInt(position);
171  NWNXCall(NWNX_SQL, "PreparedString");
172 }
173 void NWNX_SQL_PreparedFloat(int position, float value)
174 {
175  NWNXPushFloat(value);
176  NWNXPushInt(position);
177  NWNXCall(NWNX_SQL, "PreparedFloat");
178 }
179 void NWNX_SQL_PreparedObjectId(int position, object value)
180 {
181  NWNXPushObject(value);
182  NWNXPushInt(position);
183  NWNXCall(NWNX_SQL, "PreparedObjectId");
184 }
185 void NWNX_SQL_PreparedObjectFull(int position, object value, int base64 = TRUE)
186 {
187  NWNXPushInt(base64);
188  NWNXPushObject(value);
189  NWNXPushInt(position);
190  NWNXCall(NWNX_SQL, "PreparedObjectFull");
191 }
192 void NWNX_SQL_PreparedNULL(int position)
193 {
194  NWNXPushInt(position);
195  NWNXCall(NWNX_SQL, "PreparedNULL");
196 }
197 void NWNX_SQL_PreparedJson(int position, json value)
198 {
199  // Dump to string and continue as a string from here.
200  // Famously assuming we're sent valid Json here.
201  NWNX_SQL_PreparedString(position, JsonDump(value));
202 }
203 
204 
205 object NWNX_SQL_ReadFullObjectInActiveRow(int column = 0, object owner = OBJECT_INVALID, float x = 0.0, float y = 0.0, float z = 0.0, int base64 = TRUE)
206 {
207  NWNXPushInt(base64);
208  NWNXPushFloat(z);
209  NWNXPushFloat(y);
210  NWNXPushFloat(x);
211  NWNXPushObject(owner);
212  NWNXPushInt(column);
213  NWNXCall(NWNX_SQL, "ReadFullObjectInActiveRow");
214  return NWNXPopObject();
215 }
216 
218 {
219  NWNXCall(NWNX_SQL, "GetAffectedRows");
220  return NWNXPopInt();
221 }
222 
224 {
225  NWNXCall(NWNX_SQL, "GetDatabaseType");
226  return NWNXPopString();
227 }
228 
230 {
231  NWNXCall(NWNX_SQL, "DestroyPreparedQuery");
232 }
233 
235 {
236  NWNXCall(NWNX_SQL, "GetLastError");
237  return NWNXPopString();
238 }
239 
241 {
242  NWNXCall(NWNX_SQL, "GetPreparedQueryParamCount");
243  return NWNXPopInt();
244 }
245 
247 {
248  NWNXCall(NWNX_SQL, "PostgreSQL_SetNextQueryResultsBinaryMode");
249 }
int NWNX_SQL_GetPreparedQueryParamCount()
Gets the number of parameteres expected by a prepared query.
Definition: nwnx_sql.nss:240
int NWNX_SQL_ReadyToReadNextRow()
Definition: nwnx_sql.nss:142
void NWNX_SQL_PreparedObjectFull(int position, object value, int base64=TRUE)
Set the full serialized object value of a prepared statement at given position.
Definition: nwnx_sql.nss:185
string NWNX_SQL_GetDatabaseType()
Definition: nwnx_sql.nss:223
void NWNX_SQL_PreparedFloat(int position, float value)
Set the float value of a prepared statement at given position.
Definition: nwnx_sql.nss:173
void NWNX_SQL_PreparedString(int position, string value)
Set the string value of a prepared statement at given position.
Definition: nwnx_sql.nss:167
string NWNX_SQL_ReadDataInActiveRow(int column=0)
Definition: nwnx_sql.nss:153
void NWNX_SQL_DestroyPreparedQuery()
Free any resources attached to an existing prepared query.
Definition: nwnx_sql.nss:229
void NWNX_SQL_PreparedInt(int position, int value)
Set the int value of a prepared statement at given position.
Definition: nwnx_sql.nss:161
int NWNX_SQL_GetAffectedRows()
Gets the rows affected by a query.
Definition: nwnx_sql.nss:217
void NWNX_SQL_PreparedObjectId(int position, object value)
Set the ObjectId value of a prepared statement at given position.
Definition: nwnx_sql.nss:179
int NWNX_SQL_ExecutePreparedQuery()
Executes a query which has been prepared.
Definition: nwnx_sql.nss:123
object NWNX_SQL_ReadFullObjectInActiveRow(int column=0, object owner=OBJECT_INVALID, float x=0.0, float y=0.0, float z=0.0, int base64=TRUE)
Like NWNX_SQL_ReadDataInActiveRow, but for full serialized objects.
Definition: nwnx_sql.nss:205
void NWNX_SQL_PostgreSQL_SetNextQueryResultsBinaryMode()
Set the next query to return full binary results ON THE FIRST COLUMN ONLY.
Definition: nwnx_sql.nss:246
void NWNX_SQL_PreparedJson(int position, json value)
Set the Json value of a prepared statement at given position. Convienence function to match other Pre...
Definition: nwnx_sql.nss:197
int NWNX_SQL_ExecuteQuery(string query)
Directly execute an SQL query.
Definition: nwnx_sql.nss:129
int NWNX_SQL_PrepareQuery(string query)
Prepares the provided query for execution.
Definition: nwnx_sql.nss:116
string NWNX_SQL_GetLastError()
Definition: nwnx_sql.nss:234
void NWNX_SQL_ReadNextRow()
Reads the next row of returned data.
Definition: nwnx_sql.nss:148
void NWNX_SQL_PreparedNULL(int position)
Set the NULL value of a prepared statement at given position.
Definition: nwnx_sql.nss:192