Well for errors I gave the suggestion to write a wrapper function:
	PHP Code:
	
		
			
function getsql(query) {
  temp.req = requestsql(query,true);
  if (!temp.req.completed && !waitfor(temp.req,"onReceiveData",60))
    return NULL;
  if (temp.req.error!="")
    echo(temp.req.error);
  return temp.req;
} 
		
	
 For escaping use the string.escape() function.