Update lua versions
[ryzomcore.git] / web / private_php / ams / autoload / querycache.php
blobef55085b4aecf87ee249ff782329ead506350671
1 <?php
3 /**
4 * class for storing changes when shard is offline.
5 * @todo make sure that the querycache class is being used by the sync class and also for inserting the queries themselfs into it.
6 * Atm this class isn't used yet if I remember correctly
7 * @author Daan Janssens, mentored by Matthew Lagoe
8 */
10 class Querycache{
12 private $SID; /**< The queries ID */
13 private $type; /**< The type of query*/
14 private $query; /**< The query itself (json encoded) */
15 private $db; /**< the db where the query should be performed */
17 ////////////////////////////////////////////Functions////////////////////////////////////////////////////
21 ////////////////////////////////////////////Methods////////////////////////////////////////////////////
24 /**
25 * A constructor.
26 * Empty constructor
28 public function __construct() {
31 /**
32 * sets the object's attributes.
33 * @param $values should be an array of the form array('SID' => sid, 'type' => type, 'query' => query, 'db' => db).
35 public function set($values) {
36 $this->setSID($values['SID']);
37 $this->setType($values['type']);
38 $this->setQuery($values['query']);
39 $this->setDb($values['db']);
43 /**
44 * loads the object's attributes.
45 * loads the object's attributes by giving a SID as parameter
46 * @param $id the id of the querycaches row
48 public function load_With_SID( $id) {
49 $dbl = new DBLayer("lib");
50 $statement = $dbl->select("ams_querycache", array('id' => $id), "SID=:id");
51 $row = $statement->fetch();
52 $this->set($row);
56 /**
57 * updates the entry.
59 public function update(){
60 $dbl = new DBLayer("lib");
61 $dbl->update("ams_querycache", Array('type' => $this->getType(), 'query' => $this->getQuery(), 'db' => $this->getDb(), "SID=$this->getSID()" ));
64 ////////////////////////////////////////////Getters////////////////////////////////////////////////////
66 /**
67 * get SID attribute of the object.
69 public function getSID(){
70 return $this->SID;
73 /**
74 * get type attribute of the object.
76 public function getType(){
77 return $this->type;
80 /**
81 * get query attribute of the object.
83 public function getQuery(){
84 return $this->query;
87 /**
88 * get db attribute of the object.
90 public function getDb(){
91 return $this->db;
94 ////////////////////////////////////////////Setters////////////////////////////////////////////////////
96 /**
97 * set SID attribute of the object.
98 * @param $s integer id
100 public function setSID($s){
101 $this->SID = $s;
105 * set type attribute of the object.
106 * @param $t type of the query, could be changePassword, changePermissions, changeEmail, createUser
108 public function setType($t){
109 $this->type = $t;
113 * set query attribute of the object.
114 * @param $q query string
116 public function setQuery($q){
117 $this->query= $q;
121 * set db attribute of the object.
122 * @param $d the name of the database in the config global var that we want to use.
124 public function setDb($d){
125 $this->db= $d;