From 4170693210c2f27fb6617ade76d249bfafc59da5 Mon Sep 17 00:00:00 2001 From: Joey Schulze Date: Sun, 9 Jul 2017 13:29:45 +0200 Subject: [PATCH] Improve DatabaseTable for convenience --- class/databasetable.class.php | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/class/databasetable.class.php b/class/databasetable.class.php index d4eb7c0..246d012 100644 --- a/class/databasetable.class.php +++ b/class/databasetable.class.php @@ -6,6 +6,7 @@ abstract class DatabaseTable { protected $table; protected $data; protected $id; + protected $rootPath; public function __construct($table, $id=false, $column_or_db=false, $column=false) { @@ -23,6 +24,15 @@ abstract class DatabaseTable { if ($id && !$col) $this->load($id); if ($id && $col) $this->loadByColumn($id,$col); + + $path = substr($_SERVER['HTTP_REFERER'], strpos($_SERVER['HTTP_REFERER'], $_SERVER['SERVER_NAME'])+strlen($_SERVER['SERVER_NAME'])+1); + + $pos = 0; + $this->rootPath = ''; + while (($pos = strpos($path, '/', $pos)) !== false) { + $this->rootPath .= '../'; + $pos++; + } } protected function postLoad() {} @@ -81,6 +91,11 @@ abstract class DatabaseTable { $this->db->delete($this->table, $this->idcolumn, $id === false ? $this->id : $id); } + public function quote($string) { return $this->db->quote($string); } + public function execute($sql) { return $this->db->execute($sql); } + public function fetchValue($sql) { return $this->db->fetchValue($sql); } + public function fetchAssoc($sql) { return $this->db->fetchAssoc($sql); } + public function fetchAssocList($sql) { return $this->db->fetchAssocList($sql); } + public function fetchObject($sql) { return $this->db->fetchObject($sql); } + public function fetchObjectList($sql) { return $this->db->fetchObjectList($sql); } } - -?> \ No newline at end of file -- 2.20.1