gpt4 book ai didi

zend-framework - 如何在Zend Framework中定义关系

转载 作者:行者123 更新时间:2023-12-02 04:13:54 28 4
gpt4 key购买 nike

我有两个简单的表:ProjectsSubProjects,我要在表中打印每个子项目以及相应的项目。

所以我这样写:

class Admin_Model_Projects extends Zend_Db_Table_Abstract
{
protected $_name = 'main_projects';
protected $_primary = 'mai_id';
protected $_sequence = true;
protected $_dependentTables = array('Admin_Model_SubProjects');
....

和这个:
class Admin_Model_SubProjects extends Zend_Db_Table_Abstract
{
protected $_name = 'sub_projects';
protected $_primary = 'sub_id';
protected $_sequence = true;
protected $_referenceMap = array(
'columns' => 'mai_id',
'refTableClass' => 'Admin_Model_Projects',
'refColumns' => 'mai_id'
);
.....

我想知道为什么当我键入 No reference from table Admin_Model_SubProjects to table Admin_Model_Projects时得到 <?php echo $entry->findParentRow('Admin_Model_Projects'); ?>

最佳答案

看起来您在referenceMap定义中缺少规则名称。
它应该是

protected $_referenceMap = array(
'Project' => array(
'columns' => 'mai_id',
'refTableClass' => 'Admin_Model_Projects',
'refColumns' => 'mai_id'
)
);

关于zend-framework - 如何在Zend Framework中定义关系,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3754457/

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