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