php - CakePHP: Translating database 'inheritance' into app models/controllers -


i designing database system containing number of different user types. schema this:

## users  id int name varchar(60) email varchar(60)  ## doctors  id int user_id int specialism varchar(60) qualification_id int 

essentially, doctors table child of users table.

now, when i'm creating models , controllers , models in cake, thought logical create user model , subclass doctor model. doesn't seem work when testing $scaffold (the 'has one' , 'belongs to' relationships work relatively well, way not subclassing users classes).

what approach suggest database designed in way?

cakephp not designed this. cakephp uses activerecord pattern. pattern works great when models match database tables. breaks down when want set models in way trying now. setup, you'd need data mapper pattern (as implemented e.g. zend_db).

in case, set user , docter 2 separate models hasone/belongsto relation. far easier go cake-ish flow fight it.


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -