Location: PHPKode > scripts > SQL Store > sql-store/sql.cls.php
<?php
/*
  this class is the sql connection to protect all sql submited
  all querys must go via this file only this file can connect
  to the sql server this will meen this file is a critical file
  allowing the system to prevent dubble request of the same item
  if the item has allready been called in a state ment it will return the
  common type that sql would result in
*/
class sql{
  var $con;
  var $query;
  var $querys = array();
  var $output = array();

  function sql($sqlhost, $sqluser, $sqlpass, $sqldb, $sqlport=3306){
    global $config;
    $this->con = mysql_connect($sqlhost.':'.$sqlport, $sqluser, $sqlpass);
    mysql_select_db($sqldb,$this->con);
    return true;
  }
  
  function rerun(){
    if(!$key = array_search($this->query,$this->querys)){
    $this->querys[$key] = $this->query;
    $this->output[$key] = mysql_query($this->querys,$this->con);
    }
  }
  
  function query(){
    if(!$key = array_search($this->query,$this->querys)){
      $squery = mysql_query($this->query,$this->con);
      $this->querys[] = $this->query;
      $this->output[] = $this->squery;
      return $this->squery;
    }else{
      return $this->output[$key];
    }
  }

  function set_query($query){
    $this->query = $query;
    return true;
  }
  
  function fetch_assoc(){
    if(!$key = array_search($this->query,$this->querys)){
      $squery = mysql_query($this->query,$this->con);
      $row = mysql_fetch_assoc($this->squery);
      $this->querys[] = $this->query;
      $this->output[] = $row;
      return $row;
    }else{
      return $this->output[$key];
    }
  }
  
  function fetch_array(){
    if(!$key = array_search($this->query,$this->querys)){
      $squery = mysql_query($this->query,$this->con);
      $row = mysql_fetch_array($this->squery);
      $this->querys[] = $this->query;
      $this->output[] = $row;
      return $row;
    }else{
      return $this->output[$key];
    }
  }
  
?>
Return current item: SQL Store