无法解析zend_db_select中的默认架构

时间:2011-10-20 14:44:59

标签: zend-framework zend-db-select

为什么zend_db_select没有从配置文件中获取架构?我该如何解决?

配置:

resources.database.adapter = "Oracle"
resources.database.params.dbname = "(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = x.x.x.x)(PORT = 1521)) (CONNECT_DATA = (SID = xx)))"
resources.database.params.username = ''
resources.database.params.password = ''
resources.database.params.trace =
resources.database.params.schema = YYY

选择

$select->from(
                array('pm' => 'tab_1'),
                array(
                    'pm_id',
                    'status',
                    'pm_status',
                    'pm_tabno',
                    'pm_cardno',
                    'pm_start_dt',
                    'pm_endtk_dt',
                    'pm_signature',
                    'pm_servrec_no',
                    'pm_isdirector'
                )
            )
            ->joinLeft(
                array('pa' => 'tab_2'),
                'pm.pm_id = pa.pa_pm',
                array(
                    'PRL_NAME',
                    'PRF_NAME',
                    'PRS_NAME'
                )
            )
            ->joinLeft(
                array('ddpst' => 'tab_3'),
                'pm.status = ddpst.dic_value',
                'dic_name'
            )
            ->joinLeft(
                array('pst' => 'tab_4'),
                'pm.pm_status = pst.dic_value',
                'dic_sname'
            )
            ->where(
                'pa.status = 1'
        );

结果:

SELECT z2.*
            FROM (
                SELECT z1.*, ROWNUM AS "zend_db_rownum"
                FROM (
                    SELECT pm.pm_id, pm.status, pm.pm_status, pm.pm_tabno, pm.pm_cardno, pm.pm_start_dt, pm.pm_endtk_dt, pm.pm_signature, pm.pm_servrec_no, pm.pm_isdirector, pa.PRL_NAME, pa.PRF_NAME, pa.PRS_NAME, ddpst.dic_name, pst.dic_sname FROM tab_1 pm
 LEFT JOIN tab_2 pa ON pm.pm_id = pa.pa_pm
 LEFT JOIN tab_3 ddpst ON pm.status = ddpst.dic_value
 LEFT JOIN tab_4 pst ON pm.pm_status = pst.dic_value WHERE (pa.status = 1) ORDER BY PRL_NAME ASC
                ) z1
            ) z2
            WHERE z2."zend_db_rownum" BETWEEN 1 AND 50

2 个答案:

答案 0 :(得分:1)

Schema似乎不是Zend_Application_Resrouce_Db或Zend_Db_Adapter_Oracle接受的有效参数。如果使用Zend_Db_Table_Abstract来定义DbTable,则可以从DbTable类设置模式。

请参阅Example #4

答案 1 :(得分:0)

通过重写Zend_Db_Select(_join()来添加默认架构)+覆盖Zend_Db_Adapter(用于返回自己的Select)