diff options
author | Filipp Lepalaan <filipp@mekanisti.fi> | 2009-11-08 23:35:59 +0200 |
---|---|---|
committer | Filipp Lepalaan <filipp@mekanisti.fi> | 2009-11-08 23:35:59 +0200 |
commit | 71eebcefb57763451d3cc2749d2ed9e181887157 (patch) | |
tree | 1059305e84d5f5889e8306df0302398e736931ab /Controller.php | |
parent | f0bb7133827d4e36067333f70ba046e08cd53cd9 (diff) | |
download | main-71eebcefb57763451d3cc2749d2ed9e181887157.tar.gz main-71eebcefb57763451d3cc2749d2ed9e181887157.tar.bz2 main-71eebcefb57763451d3cc2749d2ed9e181887157.zip |
Lots of fixes, better url parsing
Diffstat (limited to 'Controller.php')
-rw-r--r-- | Controller.php | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/Controller.php b/Controller.php index 43b0efe..5432673 100644 --- a/Controller.php +++ b/Controller.php @@ -14,15 +14,19 @@ class Controller const OrderBy = ""; const HasMany = ""; + const TableName = ""; const ManyToMany = ""; const ForeignKey = ""; - const TableName = ""; const TableSelect = ""; function __construct($id = null) { // Child classes should always have the same name as their tables - $this->table = strtolower(get_class($this)); + $this->class = get_class($this); + $this->table = eval("return {$this->class}::TableName;"); + if (!$this->table) { + $this->table = strtolower($this->class); + } $this->result = null; if ($id) { return $this->get($id); @@ -88,10 +92,10 @@ class Controller // $this->schema = $schema[$this->table]; // Ugly hack until PHP 5.3 - $i_sort = eval("return {$this->table}::OrderBy;"); - $i_fk = eval("return {$this->table}::ForeignKey;"); - $i_mtm = eval("return {$this->table}::ManyToMany;"); - $i_select = eval("return {$this->table}::TableSelect;"); + $i_sort = eval("return {$this->class}::OrderBy;"); + $i_fk = eval("return {$this->class}::ForeignKey;"); + $i_mtm = eval("return {$this->class}::ManyToMany;"); + $i_select = eval("return {$this->class}::TableSelect;"); // $orderBy = ($sort) ? $sort : @@ -122,7 +126,7 @@ class Controller $row = $result[$i]; $this->data[$i] = $row; $this->find_parent($row, $i); - $this->find_children($row, $i); +// $this->find_children($row, $i); } return $this; @@ -136,7 +140,7 @@ class Controller private function find_children($row, $i) { $id = $row['id']; // ID of the parent - $fk = explode(",", eval("return $this->table::HasMany;")); + $fk = explode(",", eval("return $this->class::HasMany;")); if (empty($fk[0])) { return false; @@ -175,7 +179,7 @@ class Controller private function find_parent($row, $i) { $select = "*"; - $fk = explode(",", eval("return {$this->table}::ForeignKey;")); + $fk = explode(",", eval("return {$this->class}::ForeignKey;")); // No parents defined if (empty($fk[0])) { |