How do you return a dataset using MySQL
Proxy?
This being a common task, as many that we will see in these
pages, it is worth implementing with a function.
When you return a dataset, there are two main cases:
- Returning a single row with just one column. For example, when you need to give the user a simple message;
- Returning one or more rows with several columns. This is much more useful, and covers case like displaying help information, or creating a tabular set of information.
The first case is quite simple:
function simple_dataset (header, message)
proxy.response.type = proxy.MYSQLD_PACKET_OK
proxy.response.resultset = {
fields = {
{type = proxy.MYSQL_TYPE_STRING, name = header}
},
rows = {
{ message}
}
}
return …[Read more]