Вход Регистрация
Файл: include/base.php
Строк: 42
<?php

/**
    base class for game
*/

class CBase
{
    var 
$db;
    var 
$table_name;//main table
    
var $table_name_id;
    var 
$vnum;
    var 
$room_id;
    
    function 
CBase($db)
    {
        
$this->db=$db;
    }
    
    function 
unlockTable()
    {
        
$sql "UNLOCK TABLES";
        
        
$this->execSQL($sql);
    }

    function 
execSQL($sql)
    {
        
$result $this->db->query($sql);

        if (
DB::isError($result)) {
            die(
$result->toString());
            
//header("Location: fail.php");
        
}

        return 
$result;
    }

    function 
setVnum($new_vnum)
    {
        
$this->vnum=$new_vnum;
    }
    
    function 
getProperty($property)
    {
        
$sql "select $property from $this->table_name where vnum='$this->vnum' LIMIT 1";

        
$result $this->execSQL($sql);
        
        if(
$result->numRows()==0) return false;
    
        
$row $result->fetchRow();
        
        
$result->free();

        return 
$row[0];
  }
  
  function 
setProperty($property,$value)
  {
        
$sql "update $this->table_name set $property='$value' where vnum='$this->vnum' LIMIT 1";

        
$this->execSQL($sql);
  }
  
  function 
changeProperty($property,$diff)
  {
          
$sql "update $this->table_name set $property=$property+'$diff' where vnum='$this->vnum' LIMIT 1";
          
          
$this->execSQL($sql);
  }
}

?>
Онлайн: 1
Реклама