Файл: include/player_transfer.php
Строк: 156
<?php
include_once("table_name.php");
include_once("base.php");
include_once("common_func.php");
/**
class player transfer object
*/
class CPlayerTransfer extends CBase
{
/**
Constructor
*/
function CPlayerTransfer($database,$vnum = 0)
{
$this->db=$database;
$this->table_name=$GLOBALS['table_transfer'];
$this->vnum=$vnum;
}
/**
Add thing to temporaly tables
*/
function transferThing($vnum_obj,$from,$to,$count,$cost,$durability,$max_durability,$comments)
{
$vnum = getUniqID();
//need add things
$sql = "insert into $this->table_name(vnum,vnum_obj,vnum_player_from,vnum_player_to,count,cost,durability,max_durability,comments)".
"values ('$vnum','$vnum_obj','$from','$to','$count','$cost','$durability','$max_durability','$comments')";
$this->execSQL($sql);
}
/**
Get list transfer things
*/
function getListTransferThings()
{
$sql = "select vnum_obj,vnum_player_from,count,cost,durability,max_durability,comments,vnum from $this->table_name where vnum_player_to='$this->vnum'";
$result = $this->execSQL($sql);
$thing = array();
//cycle on all things
while($row = $result->fetchRow())
{
$thing[]=array("vnum_obj" => $row[0],
"vnum_player_from" => $row[1],
"count" => $row[2],
"cost" => $row[3],
"durability" => $row[4],
"max_durability" => $row[5],
"comments" => $row[6],
"vnum" => $row[7],
);
}
return $thing;
}
/**
Get list player make transfer
*/
function getListPlayerTransferThings()
{
$sql = "select vnum_obj,vnum_player_to,count,cost,durability,max_durability,comments,vnum from $this->table_name where vnum_player_from='$this->vnum'";
$result = $this->execSQL($sql);
$thing = array();
//cycle on all things
while($row = $result->fetchRow())
{
$thing[]=array("vnum_obj" => $row[0],
"vnum_player_to" => $row[1],
"count" => $row[2],
"cost" => $row[3],
"durability" => $row[4],
"max_durability" => $row[5],
"comments" => $row[6],
"vnum" => $row[7],
);
}
return $thing;
}
/**
Get one transfer thing
*/
function getTransferThing($id)
{
$sql = "select vnum_obj,vnum_player_from,count,cost,durability,max_durability,comments,vnum from $this->table_name where vnum_player_to='$this->vnum' and vnum='$id'";
$result = $this->execSQL($sql);
if($result->numRows()==0) return false;
$row = $result->fetchRow();
$thing=array("vnum_obj" => $row[0],
"vnum_player_from" => $row[1],
"count" => $row[2],
"cost" => $row[3],
"durability" => $row[4],
"max_durability" => $row[5],
"comments" => $row[6],
"vnum" => $row[7],
);
return $thing;
}
/**
Get one player transfer thing
*/
function getPlayerTransferThing($id)
{
$sql = "select vnum_obj,vnum_player_to,count,cost,durability,max_durability,comments,vnum from $this->table_name where vnum_player_from='$this->vnum' and vnum='$id'";
$result = $this->execSQL($sql);
if($result->numRows()==0) return false;
$row = $result->fetchRow();
$thing=array("vnum_obj" => $row[0],
"vnum_player_to" => $row[1],
"count" => $row[2],
"cost" => $row[3],
"durability" => $row[4],
"max_durability" => $row[5],
"comments" => $row[6],
"vnum" => $row[7],
);
return $thing;
}
/**
Delete transfer
*/
function deleteTransfer($id)
{
$sql = "delete from $this->table_name where vnum='$id'";
$this->execSQL($sql);
}
}
?>