shop.balmet.com

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

ebay_template.php (2072B)


      1 <?php
      2 class ModelExtensionOpenBayEbayTemplate extends Model {
      3 	public function add($data) {
      4 		$this->db->query("INSERT INTO `" . DB_PREFIX . "ebay_template` SET `name` = '" . $this->db->escape($data['name']) . "', `html` = '" . $this->db->escape($data['html']) . "'");
      5 		return $this->db->getLastId();
      6 	}
      7 
      8 	public function edit($id, $data) {
      9 		$this->db->query("UPDATE `" . DB_PREFIX . "ebay_template` SET `name` = '" . $this->db->escape($data['name']) . "', `html` = '" . $this->db->escape($data['html']) . "' WHERE `template_id` = '" . (int)$id . "' LIMIT 1");
     10 	}
     11 
     12 	public function delete($id) {
     13 		$qry = $this->db->query("DELETE FROM `" . DB_PREFIX . "ebay_template` WHERE `template_id` = '" . (int)$id . "' LIMIT 1");
     14 
     15 		if ($qry->countAffected() > 0) {
     16 			return true;
     17 		}else{
     18 			return false;
     19 		}
     20 	}
     21 
     22 	public function get($id) {
     23 		$qry = $this->db->query("SELECT * FROM `" . DB_PREFIX . "ebay_template` WHERE `template_id` = '" . (int)$id . "' LIMIT 1");
     24 
     25 		if ($qry->num_rows) {
     26 			$row = $qry->row;
     27 			$row['link_edit'] = $this->url->link('extension/openbay/ebay_template/edit&user_token=' . $this->session->data['user_token'] . '&template_id=' . $row['template_id'], true);
     28 			$row['link_delete'] = $this->url->link('extension/openbay/ebay_template/delete&user_token=' . $this->session->data['user_token'] . '&template_id=' . $row['template_id'], true);
     29 
     30 			return $row;
     31 		}else{
     32 			return false;
     33 		}
     34 	}
     35 
     36 	public function getAll() {
     37 		$qry = $this->db->query("SELECT * FROM `" . DB_PREFIX . "ebay_template`");
     38 
     39 		$templates = array();
     40 
     41 		if($qry->num_rows) {
     42 			foreach($qry->rows as $row) {
     43 				$row['link_edit'] = $this->url->link('extension/openbay/ebay_template/edit&user_token=' . $this->session->data['user_token'] . '&template_id=' . $row['template_id'], true);
     44 				$row['link_delete'] = $this->url->link('extension/openbay/ebay_template/delete&user_token=' . $this->session->data['user_token'] . '&template_id=' . $row['template_id'], true);
     45 				$templates[] = $row;
     46 			}
     47 		}
     48 
     49 		return $templates;
     50 	}
     51 }