Skip to content

Instantly share code, notes, and snippets.

@g33klord
Created January 30, 2014 05:25
Show Gist options
  • Save g33klord/8703051 to your computer and use it in GitHub Desktop.
Save g33klord/8703051 to your computer and use it in GitHub Desktop.
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