db = &$db; $this->tpl = &$tpl; $this->error = &$error; $this->cache = &$cache; } public function trim (&$data) { foreach ($data as $key => $value) { if (! is_array ($data[$key])) { $data[$key] = trim ($value); } } } public function valid ($data, $upload = null) { return true; } public function getAll () { return $this->db->getAll(' SELECT * FROM `extra` INNER JOIN `extra_status` ON `extra_status`.status_id = `extra`.status_id ', array (), DB_FETCHMODE_ASSOC); } public function init () { // assign var $this->tpl->assign('mass', array ( 'extra' => $this->getAll(), )); // assign template $this->tpl->assign("tpl", "extra.tpl"); } public function getOneByName ($NAME) { return $this->db->getRow(' SELECT * FROM `extra` INNER JOIN `extra_status` ON `extra_status`.status_id = `extra`.status_id WHERE `extra`.extra_name=? ', array ($NAME), DB_FETCHMODE_ASSOC); } public function getOneById ($id) { return $this->db->getRow(' SELECT * FROM `extra` INNER JOIN `extra_status` ON `extra_status`.status_id = `extra`.status_id WHERE `extra`.extra_id=? ', array ($id), DB_FETCHMODE_ASSOC); } public function getStatusIdByName ($NAME) { $result = $this->getOneByName ($NAME); return $result['status_id']; } public function setExtraStatus ($param) { return $this->db->query(' UPDATE `extra` SET status_id = '.(int)$param['status_id'].' WHERE extra_id = '.(int)$param['extra_id'].' '); } public function displaySnow () { return ' '; // } }