我对这样的查询有疑问:
$sSqlAux = $this->select()->setIntegrityCheck(false)
->from(array("a_aux" => $this->_name), "id_a", $this->_schema)
->join(array("b_aux"=> "b"), "a_aux.id_a = b_aux.id_b", array(), $this->_schema)
->join(array("c_aux"=> "c"), "a_aux.id_inscrito = c_aux.id_c", array(), $this->_schema)
->where("b_aux.id_b = ?", $this->idB)
;
$sSql = $this->select()->setIntegrityCheck(false)
->from(array("a" => $this->_name), "a.id_a, a.campo_a", $this->_schema)
->joinLeft(array("b" => "b"), "a.id_a = b.id_b", "b.campo_b", $this->_schema)
->joinLeft(array("c" => "c"), "b.id_b = c.id_c", "c.campo", $this->_schema)
->where("c.campo_c = ?", "string")
->where("a.id_a IN (?)", new Zend_Db_Expr($sSqlAux))
->order("c.campo_c")
;
并返回数据,在表名之前添加一个星号,在这种情况下,在我的左连接之一中,表 b ( LEFT JOIN schema.*b ON a.id_a = b.id_b ) 如下例所示
SELECT
a.id_a,
a.campo_a
b.campo_b,
c.campo_c
FROM schema.a a
LEFT JOIN schema.*b ON a.id_a = b.id_b
LEFT JOIN schema.c c ON a.id_a = c.id_c
WHERE (c.campo_c = 'string')
AND (a.id_a IN (
SELECT a_aux.id_a
FROM schema.a a_aux
INNER JOIN schema.b b_aux ON a_aux.id_a = b_aux.id_b
INNER JOIN schema.c c_aux ON a_aux.id_a = c_aux.id_c
WHERE (a_aux.id_segundo_id = 5321)))
ORDER BY c.campo ASC
)
这些只是我遇到的问题的示例,如果我的输入中有逻辑错误或语法错误。真正的问题是 zend 在连接中的表名之前添加的星号。
如果有人理解了这个问题并有一个可以分享的解决方案,那将会有很大的帮助。
我正在使用zend 1
谢谢!