| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- <?php
- require_once(__DIR__."/database.php");
- class Tax
- {
- function __construct()
- {
- $this->db = new Database();
- }
- function create($name, $rate)
- {
- $query = "INSERT INTO ".$this->db->tax_table." (name, tax_rate) VALUES ('".str_replace("'", "\'", $name)."', ".$rate.")";
- $this->db->query($query);
- }
- function update($tax_id, $value)
- {
- $query = "UPDATE ".$this->db->tax_table." SET ";
- $query .= "name='".str_replace("'", "\'", $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));
- }
- }
- }
- ?>
|