Jos*_*eda 2 php sql zend-framework
尝试使用Zend_Db_Select. 任何指针?
SELECT
compounds.id as compounds_id,
reactions.id as reactions_id,
reaction_compound.number as reaction_compound_number
FROM compounds, reactions, reaction_compound
WHERE
compounds.id IN (68,74,112)
AND compounds.id = reaction_compound.compound
AND reactions.id = reaction_compound.reaction;
Run Code Online (Sandbox Code Playgroud)
具体来说,我遇到的一些问题是在 Zend 中执行多个表连接。我不确定如何使用他们的查询构建器跨多个表进行连接。
任何帮助表示赞赏!
J
像这样的东西:
$compoundIds = array(68,74,112);
$select = $db->select()
->from('compounds', array('compounds_id' => 'id')
->where('compounds.id in ( ? )', $compoundIds)
->join('reaction_compound', 'compounds.id = reaction_compound.compound', array('reaction_compound_number' => 'number'))
->join('reactions', 'reactions.id = reaction_compound.reaction', array('reaction_id' => 'id');
Run Code Online (Sandbox Code Playgroud)
那应该可以带你去某个地方。我没有测试它,所以那里可能有一些错误。