-
-
Save g33klord/8703051 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Teacher Model: | |
<?php | |
class Teacher extends AppModel { | |
public $actsAs = array('Containable'); | |
public $hasOne = array('Subject'); | |
Subject Model: | |
<?php | |
class Subject extends Model { | |
public $actsAs = array('Containable'); | |
public $belongsTo= array('Teacher'); | |
Teacher Controller: | |
<?php | |
class TeachersController extends AppController { | |
var $components=array('Email','Session'); | |
var $helpers=array('Html','Form','Session'); | |
var $uses = array('Teacher','Subject'); | |
public function index() { | |
$results = $this->Teacher->find('all',array('contain'=>array('Subject'))); //Should return Teacher + Subject as well | |
$this->set('results', $results); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment