| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- <?php
- require_once("../DataBase/database.php");
- class Priceset
- {
- function Priceset()
- {
- $this->db = new Database();
- }
- function create($priceset_id, $value)
- {
- $query = "INSERT INTO ".$this->db->priceset_table." VALUES('".$priceset_id."'";
- for($i = 0; $i < count($value); $i++)
- $query .= ", '".$value[$i]."'";
- $query .= ")";
- $this->db->query($query);
- }
- function update($priceset_id, $value)
- {
- $query = "UPDATE ".$this->db->priceset_table." SET ";
- $query .= "name='".$value[0]."', ";
- $query .= "netto='".$value[1]."' ";
- $query .= "WHERE priceset_id='".$priceset_id."'";
- $this->db->query($query);
- }
- function delete($priceset_id)
- {
- $query = "DELETE FROM ".$this->db->priceset_table." WHERE priceset_id='$priceset_id'";
- $this->db->query($query);
- }
- function exists($priceset_id)
- {
- $query = "SELECT priceset_id FROM ".$this->db->priceset_table." WHERE priceset_id='".$priceset_id."'";
- $result = $this->db->fetchRows($this->db->query($query));
- if(count($result) > 0)
- return true;
- else
- return false;
- }
- function get($priceset_id = "", $row_names = array(), $search = "")
- {
- if($priceset_id == "")
- {
- if(count($row_names) == 0)
- $query = "SELECT * FROM ".$this->db->priceset_table;
- else
- {
- $query = "SELECT ".$row_names[0];
- for($i = 1; $i < count($row_names); $i++)
- $query .= ", ".$row_names[$i];
- $query .= " FROM ".$this->db->priceset_table;
- }
- if($search != "")
- $query .= " WHERE ".$search;
- $query .= " ORDER BY priceset_id ASC";
- return $this->db->fetchRows($this->db->query($query));
- }
- else
- {
- if(count($row_names) == 0)
- $query = "SELECT * FROM ".$this->db->priceset_table;
- else
- {
- $query = "SELECT ".$row_names[0];
- for($i = 1; $i < count($row_names); $i++)
- $query .= ", ".$row_names[$i];
- $query .= " FROM ".$this->db->priceset_table;
- }
- $query .= " WHERE priceset_id='".$priceset_id."'";
- $query .= " ORDER BY priceset_id ASC";
- return $this->db->fetchRows($this->db->query($query));
- }
- }
- }
- ?>
|