Interested in improving this site? Please check the To Do page.
mysql.clearQuery
Clear a MySQL query.
Syntax
mysql.clearQuery(queryid)
Params
A query id
Returns
0
Examples
on querysample () {
local (id, result, queryID, sql);
result = mysql.init();
id = mysql.connect("localhost", "root", "frontier", "frontier", 3306);
queryID = mysql.compileQuery(id, "select * from names");
dialog.alert("Selected row count: " + mysql.getSelectedRowCount(queryID));
dialog.alert("Column count: " + mysql.getColumnCount(id));
dialog.alert("Query warnings: " + mysql.getQueryWarningCount(id));
dialog.alert("Query info: " + mysql.getQueryInfo(id));
loop {
result = mysql.getRow(queryID);
if result == 0 {
break};
dialog.alert(result)};
mysql.clearQuery(queryID);
result = mysql.close(id);
result = mysql.end();
return result}
on easyQuery(dbID, queryString, maxRows=0) {
local (compiledQuery, dataset = {}, row, rowCount = 0);
on isNum(s) {
for i = 1 to string.length(s) {
ch = string.mid(s, i, 1);
if (ch < '0') or (ch > '9') {
return false}};
return true};
if not isNum(maxRows) {
scriptError("mysql.easyQuery requires a numeric value for maxRows.")};
compiledQuery = mysql.compileQuery(dbID, queryString); // this will scriptError on its own if it fails
if compiledQuery > 0 {
loop {
result = mysql.getRow(compiledQuery);
if result == 0 { // MySQL's code for no more rows
break};
++rowCount;
if (maxRows > 0) and (rowCount > maxRows) {
break};
dataset[rowCount] = result};
mysql.clearQuery(compiledQuery)}
else {
return {}};
return dataset}
Notes
MySQL returns nothing from the mysql_free_result call, which is what Frontier's mysql.clearQuery calls. So there's no real point in doing any error checking here, although you might want to test the general MySQL error functions.