Use the rows from the SQL result.
PHP Code:
temp.data = req("your sql query");
for (temp.row: temp.data.rows) {
temp.ids.add(temp.row.rowid);
}
echo(temp.ids);
Also escape/validate your params in the SQL query. I.e: escapestring2(params[1]) or for numbers int(params[1]) or float(params[1]).