Initial import: Carteasy Shop (Dev-Stand)
This commit is contained in:
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
/*
|
||||
* @version $Id: index.php 10381 2008-06-01 03:35:53Z $
|
||||
* @package Carteasy
|
||||
* @copyright Copyright (C) 2005 - 2011 Wlanium
|
||||
* @license proprietary
|
||||
* @author Thomas Bartelt
|
||||
* Carteasy is a web shop system
|
||||
*/
|
||||
|
||||
class Cache {
|
||||
|
||||
private $object_fields = array(
|
||||
'id' => 'text',
|
||||
'timestamp' => 'text',
|
||||
'data' => 'text'
|
||||
);
|
||||
|
||||
private $base_object;
|
||||
|
||||
function __construct($base_object) {
|
||||
|
||||
$this->base_object = $base_object;
|
||||
$this->db = $base_object->db;
|
||||
} // end __construct
|
||||
|
||||
public function get_data($id) {
|
||||
if ($this->id) {
|
||||
$sql = "SELECT *
|
||||
FROM cache
|
||||
WHERE id='".$this->db->real_escape_string($id)."'";
|
||||
|
||||
$result = $this->db->query($sql);
|
||||
$obj = $result->fetch_object();
|
||||
if ($obj) {
|
||||
return $obj;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
} // end get_data
|
||||
|
||||
public function delete($id) {
|
||||
$sql = "DELETE FROM cache
|
||||
WHERE id='".$this->db->real_escape_string($id)."'";
|
||||
|
||||
$this->db->query($sql);
|
||||
|
||||
return;
|
||||
}// end delete
|
||||
|
||||
public function set($data) {
|
||||
if ($data) {
|
||||
$sql = "INSERT INTO countries
|
||||
SET ";
|
||||
|
||||
foreach ($data as $var_name => $value) {
|
||||
$value = $this->db->real_escape_string($value);
|
||||
if ($this->object_fields[$var_name] == 'integer') {
|
||||
$sql .= $var_name.' = '.$value.', ';
|
||||
}
|
||||
else {
|
||||
$sql .= $var_name.' = "'.$value.'", ';
|
||||
}
|
||||
}
|
||||
$sql = substr($sql, 0, -2);
|
||||
$this->db->query($sql);
|
||||
$this->id = $this->db->insert_id;
|
||||
}
|
||||
|
||||
return;
|
||||
} // end create
|
||||
|
||||
} // end Country
|
||||
Reference in New Issue
Block a user