【发布时间】:2012-03-04 21:51:53
【问题描述】:
我认为我遇到了 phpactiverecord 的限制,但需要澄清:
$data = array(
'conditions' => array(
'still_in_contest' => 1,
'contest_month' => $month,
'`genres`.`id`' => $genre, # THIS is the issue.. and an awkward "hack" that
# I was hoping would work..
)
'include' => array('song' => array('artist','genre')),
'joins' => array('
LEFT JOIN songs
ON (songs.id = contest_submissions.song_id)
LEFT JOIN genres
ON (genres.id = songs.genre_id)',
),
难道不能简单地在查询中添加genres.id 之类的内容吗?
phpactiverecord 将查询设置为:
WHERE `contest_submissions`.`genres`.`id`=?
如果有其他方法仍然可以从自动加载另一个类似查询中受益,而无需我自己做所有事情?
编辑: 我现在的解决方案是只修改 phpactiverecord 的 SQLBuilder 类的核心,如果键中有一个点,则不附加表的名称......
编辑2:
我尝试了您的解决方案 Nanne,但没有成功。 Phpactiverecord 最终将表名添加到所有内容中。 :(
$genre = 1
if($genre)
$data['conditions']['genres.id'] = $genre;
$data['conditions']['contest_submissions.still_in_contest'] = 1;
$data['conditions']['contest_submissions.contest_month'] = $month;
之前成功了,因为我保留了我的 hack。我是否错误地格式化了条件?
EDIT3:
是的..是的,我确实格式不正确。
【问题讨论】:
标签: php phpactiverecord