View Single Post
  #4  
Old 05-19-2007, 02:57 AM
Rapidwolve Rapidwolve is offline
Registered User
Join Date: Jul 2006
Posts: 1,241
Rapidwolve is an unknown quantity at this point
Okay added a new function and replaced an old one.
PHP Code:
RequestSQL(hostusernamepasswordquery); 
is now

PHP Code:
RequestSQL2(hostusernamepassworddbquery); 
and the new RequestSQL is:

PHP Code:
RequestSQL(query); 
Uses default SQL settings.

-------------------

Updated Class [sql_functions]:
PHP Code:
/*
      CREATED BY RAPIDWOLVE
*/
function SQL_Update(tablefieldnewvaluerow)
{
  
temp.query format("UPDATE `%s` SET `%s` = '%s' WHERE `ID` = %s"temp.tabletemp.fieldtemp.newvaluetemp.row);
  return 
temp.query;
}

function 
SQL_Delete(tablefieldvalue)
{
  
temp.query format("DELETE FROM `%s` WHERE `%s` = '%s';"temp.tabletemp.fieldtemp.value);
  return 
temp.query;
}

function 
SQL_Insert(tablefieldvalue)
{
  if ((
temp.field.size() == temp.value.size()) && temp.field.size() > 1)
  {
    
temp.query format("INSERT INTO `%s` ("temp.table);
    
    for (
0temp.field.size(); ++)
    {
      
temp.query @= "`" temp.field[i] @ "`";
      if (
temp.field.size()-1)
        
temp.query @= " , ";
    }
    
    
temp.query @= ") VALUES (";
    
    for (
0temp.value.size(); j++)
    {
      
temp.query @= "'" temp.value[j] @ "'";
      if (
temp.value.size()-1)
        
temp.query @= " , ";
    }
    
    
temp.query @= ");";
    return 
temp.query;
    
  } else {
    
temp.query format("INSERT INTO `%s` (`%s`) VALUES ('%s')"temp.tabletemp.fieldtemp.value);
    return 
temp.query;
  }
}

function 
RequestSQL(query)
{
  
temp.url format("%s?host=%s&user=%s&pass=%s&db=%s&query=%s"this.sql.connectfilethis.sql.hostthis.sql.usernamethis.sql.passwordthis.sql.dbtemp.query);
  
temp.req requesturl(temp.url);
  
this.catchevent(temp.req"onReceiveData""onSQLReceived");
}

function 
RequestSQL2(hostusernamepassworddbquery)
{
  
temp.url format("%s?host=%s&user=%s&pass=%s&db=%s&query=%s"this.sql.connectfiletemp.hosttemp.usernametemp.passwordtemp.dbtemp.query);
  
temp.req requesturl(temp.url);
  
this.catchevent(temp.req"onReceiveData""onSQLReceived");
}

function 
onSQLReceived(page)
{
  
temp.returnData page.data[0];
  for (
pallplayers)
  {
    if (
== "rapidwolve")    // RC Player
      
p.sendpm(temp.returnData);
  }

-----------------

Quote:
Originally Posted by JkWhoSaysNi
I suggest you put the SQL connection details in the PHP script though. That way you can safely use the script clientside without worrying about people getting your DB info.
Will probobly make it like that once im done with all the SQL format functions, thanks for the advice.
Reply With Quote