Commit 9606848d authored by Alexander Butenko's avatar Alexander Butenko

Fix for with() and autoload()

parent 9aceb949
...@@ -271,6 +271,7 @@ class dbObject { ...@@ -271,6 +271,7 @@ class dbObject {
private function getOne ($fields = null) { private function getOne ($fields = null) {
$results = $this->db->getOne ($this->dbTable, $fields); $results = $this->db->getOne ($this->dbTable, $fields);
$this->processArrays ($results); $this->processArrays ($results);
$this->data = $results;
$this->processWith ($results); $this->processWith ($results);
if ($this->returnType == 'Array') if ($this->returnType == 'Array')
return $results; return $results;
...@@ -296,6 +297,7 @@ class dbObject { ...@@ -296,6 +297,7 @@ class dbObject {
$results = $this->db->get ($this->dbTable, $limit, $fields); $results = $this->db->get ($this->dbTable, $limit, $fields);
foreach ($results as &$r) { foreach ($results as &$r) {
$this->processArrays ($r); $this->processArrays ($r);
$this->data = $r;
$this->processWith ($r); $this->processWith ($r);
if ($this->returnType == 'Object') { if ($this->returnType == 'Object') {
$item = new static ($r); $item = new static ($r);
...@@ -446,6 +448,7 @@ class dbObject { ...@@ -446,6 +448,7 @@ class dbObject {
return; return;
foreach ($this->_with as $w) foreach ($this->_with as $w)
$data[$w] = $this->$w; $data[$w] = $this->$w;
$this->_with = Array(); $this->_with = Array();
} }
...@@ -556,8 +559,9 @@ class dbObject { ...@@ -556,8 +559,9 @@ class dbObject {
} }
private static function dbObjectAutoload ($classname) { private static function dbObjectAutoload ($classname) {
$filename = "models/". $classname .".php"; $filename = static::$modelPath . $classname .".php";
include ($filename); if (file_exists ($filename))
include ($filename);
} }
/* /*
......
...@@ -121,6 +121,13 @@ if (!is_array ($product['userId'])) { ...@@ -121,6 +121,13 @@ if (!is_array ($product['userId'])) {
exit; exit;
} }
$product = product::with('userId')->byId(5);
if (!is_object ($product->data['userId'])) {
echo "Error in with processing in getOne object";
exit;
}
$products = product::ArrayBuilder()->with('userId')->get(2); $products = product::ArrayBuilder()->with('userId')->get(2);
if (!is_array ($products[0]['userId'])) { if (!is_array ($products[0]['userId'])) {
echo "Error in with processing in get"; echo "Error in with processing in get";
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment