开发者

Joining 3 tables in Symfony Propel Database ORM

开发者 https://www.devze.com 2023-02-25 05:47 出处:网络
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 h

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

精彩评论

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

关注公众号