开发者

Joining 3 tables in Symfony Propel Database ORM

I'm building a job portal. I'm using symfony 1.1 framework which uses Propel database 开发者_Python百科engine. I have three tables such as user, job and job_applied. user table has uid , job table has jid and job_applied has uid and jid . I need to get job title, description, position of job table according to uid and jid of job_applied table.


$c = new Criteria();
$c->addJoin(JobAppliedPeer::JID, JobPeer::JID);
$c->addJoin(JobAppliedPeer::UID, UserPeer::UID);
$c->add (whatever other criteria you need);

$apps = JobAppliedPeer::doSelect($c);

for ($apps as $app) {
 $jt = $app->getJob()->getJobTitle();
}

etc.

You may need to adjust this a bit because of your column names: I always use a column name like 'job_id' for foreign keys like this, and then Propel automatically generates accessor methods 'getJob' and 'getJobId'.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜