无法解析 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
why zend_db_select does not pick up schema from config file? and how can i fix it?
config:
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:
$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'
);
result:
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Schema 似乎不是 Zend_Application_Resrouce_Db 或 Zend_Db_Adapter_Oracle 接受的有效参数。如果您使用 Zend_Db_Table_Abstract 来定义 DbTable,则可以从 DbTable 类设置模式。
请参阅示例#4。
Schema doesn't appear to be a valid parameter accepted by Zend_Application_Resrouce_Db or Zend_Db_Adapter_Oracle. You can set the schema from your DbTable classes if you are using Zend_Db_Table_Abstract to define your DbTables.
See Example #4.
通过重写 Zend_Db_Select (_join() 用于添加默认模式)+重写 Zend_Db_Adapter (用于返回自己的 Select)来解决
rsolved by overriding Zend_Db_Select (_join() for adding default schema) + overriding Zend_Db_Adapter (for returning own Select)