View Single Post
  #2  
Old 03-11-2010, 09:47 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
I started writing a tutorial for it, but never finished. It's a good starting point, though. You can find it here.

Once you've gotten a basic understanding, I'm willing to answer any questions you have (and I'm sure others are too).

EDIT: Oh, I see what you mean.

PHP Code:
function onCreated() {
  
temp.request requestsql("SELECT * FROM bank"true);
  
  
waitFor(request"onReceiveData"60);
  
  for (
temp.row request.rows) {
    echo(
row.account ": " row.money);
  }

You use the command requestsql(str query, bool expectReturn). I find it useful to write your own wrapper function.

PHP Code:
function req(queryexpect) {
  
temp.req requestsql(queryexpect);
  
  if (
expect) {
    
waitFor(req"onReceiveData"60);
  }
  
  if (
req.error != null) {
    echo(
"SQL Error: " req.error);
    echo(
"  Query: " query);
  }
  
  return 
req;

Then you would use it like

PHP Code:
temp.query req("SELECT * FROM bank"true);

for (
temp.row query.rows) {
  echo(
row.account ": " row.money);

Eventually you'll also want to be able to select a database, too... something like this:
PHP Code:
function req(dbqueryexpect) {
  
temp.req requestsql2(dbqueryexpect);
  
  if (
expect) {
    
waitFor(req"onReceiveData"60);
  }
  
  if (
req.error != null) {
    echo(
"SQL Error (" db ": " req.error);
    echo(
"  Query: " query);
  }
  
  return 
req;

__________________

Last edited by cbk1994; 03-11-2010 at 10:00 AM..
Reply With Quote