gpt4 book ai didi

php - 具有多个表连接的 Zend DB Select

转载 作者:行者123 更新时间:2023-12-05 01:22:07 25 4
gpt4 key购买 nike

尝试使用 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;

具体来说,我遇到的一些问题是在 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');

这应该能带你到某个地方。我没有测试它,所以那里可能有一些错误。

关于php - 具有多个表连接的 Zend DB Select,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1884313/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com