orm - One table two model -


i have posts table
id
type enum(a,q)
title
content

and need controllers questions_controller , answer_controller use
please lead right way to

1-
make 2 models (question , answer) , use 'posts' model's table

2-
use post model in questions_controller , answer_controller

for me, should one table has 1 model

so better use $uses = array('post'); in controllers.

update: far understood want filter data depending type column. db model wrong, because except if totally unrelated answers need belong question. mean need column parent_id determine parent node (question) , child nodes (answers).

if have assumption, can set relation in model like:

class post extends appmodel {    ...    var $belongsto = array(       'parent' => array('classname' => 'post','foreignkey' => 'parent_id', 'conditions' => 'parent.parent_id not null')    );    ... } 

so automatically have post , post->parent. think better have 2 tables - 1 holds questions , answers.


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -