Created
January 26, 2011 21:35
-
-
Save jaredhoyt/797517 to your computer and use it in GitHub Desktop.
Polymorphic - example usage
This file contains 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
<?php | |
class AppModel extends Model { | |
function __construct($id = false, $table = null, $ds = null) { | |
parent::__construct($id, $table, $ds); | |
if (isset($this->hasMany['Note'])) { | |
$this->hasMany['Note']['conditions']['Note.class'] = $this->name; | |
$this->hasMany['Note']['foreignKey'] = 'foreign_id'; | |
} | |
} | |
} |
This file contains 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
<?php | |
class Customer extends AppModel { | |
var $hasMany = array('Note'); | |
} |
This file contains 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
<?php | |
class Note extends AppModel { | |
var $actsAs = array('Polymorphic.Polymorphic'); | |
var $belongsTo = array('Customer'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment