summaryrefslogtreecommitdiffstats
path: root/application/classes
diff options
context:
space:
mode:
authorRoman Tsiupa <draconyster@gmail.com>2013-01-18 03:32:22 +0200
committerRoman Tsiupa <draconyster@gmail.com>2013-01-18 03:32:22 +0200
commit25ae5646139bcc0d4303d85fc95772f4f5dc0410 (patch)
tree8b408fe682a45ce20aa7f605efe3c31706aad296 /application/classes
parent13a2246037b5a7cc4c610853af78759d6e1ba63f (diff)
downloadPHPixie-25ae5646139bcc0d4303d85fc95772f4f5dc0410.zip
PHPixie-25ae5646139bcc0d4303d85fc95772f4f5dc0410.tar.gz
PHPixie-25ae5646139bcc0d4303d85fc95772f4f5dc0410.tar.bz2
ORM Module finished
Diffstat (limited to 'application/classes')
-rw-r--r--application/classes/controller/home.php5
-rw-r--r--application/classes/model/fairy.php2
-rw-r--r--application/classes/model/flower.php5
-rw-r--r--application/classes/model/tree.php1
4 files changed, 11 insertions, 2 deletions
diff --git a/application/classes/controller/home.php b/application/classes/controller/home.php
index 3b9dbf3..7ec6e86 100644
--- a/application/classes/controller/home.php
+++ b/application/classes/controller/home.php
@@ -2,7 +2,10 @@
class Home_Controller extends Controller {
public function action_index(){
- print_r(ORM::factory('fairy')->with('tree')->find_all()->as_array(true));
+ foreach(ORM::factory('fairy')->with ('tree.protector','tree.flower.protector')->find_all() as $fairy) {
+ echo $fairy->tree->protector->name;
+
+ }
}
}
diff --git a/application/classes/model/fairy.php b/application/classes/model/fairy.php
index 31a942a..e5a8678 100644
--- a/application/classes/model/fairy.php
+++ b/application/classes/model/fairy.php
@@ -1,4 +1,4 @@
<?php
class Fairy_Model extends ORM{
- public $belongs_to=array('tree');
+ public $belongs_to=array('tree','flower');
} \ No newline at end of file
diff --git a/application/classes/model/flower.php b/application/classes/model/flower.php
new file mode 100644
index 0000000..b817a7d
--- /dev/null
+++ b/application/classes/model/flower.php
@@ -0,0 +1,5 @@
+<?php
+class Flower_Model extends ORM{
+ public $has_many=array('fairies');
+ public $belongs_to=array('protector'=>array('model'=>'fairy','key'=>'protector_id'));
+} \ No newline at end of file
diff --git a/application/classes/model/tree.php b/application/classes/model/tree.php
index 0c4973d..721372e 100644
--- a/application/classes/model/tree.php
+++ b/application/classes/model/tree.php
@@ -1,4 +1,5 @@
<?php
class Tree_Model extends ORM{
public $has_many=array('fairies');
+ public $belongs_to=array('protector'=>array('model'=>'fairy','key'=>'protector_id'),'flower');
} \ No newline at end of file