坚持 zend_db_table +加入
尝试了解如何使用 Zend_Db_Table
。
我有一个这样的表:
然后我创建了类:
class table_1 extends Zend_Db_Table_Abstract
{
protected $_name = 'table_1';
protected $_primary = 't1_id';
protected $_referenceMap = array(
'DepCard' => array(
'columns' => 't1_id',
'refTableClass' => 'table_2',
'refColumns' => 't2_t1'
),
'Select1' => array(
'columns' => array('t1_select1'),
'refTableClass' => 'Select_1'
),
'Select2' => array(
'columns' => array('t1_select2'),
'refTableClass' => 'Select_2'
)
);
}
class table_2 extends Zend_Db_Table_Abstract {
protected $_dependentTables = array('table_1');
}
class Select_1 extends Zend_Db_Table_Abstract {
protected $_dependentTables = array('table_1');
}
class Select_2 extends Zend_Db_Table_Abstract{
protected $_dependentTables = array('table_1');
}
然后我想:
$table_1 = new table_1();
$data = $table_1->fetchAll();
与所有依赖表。 有什么办法可以做到这一点吗?
trying to understand of using Zend_Db_Table
.
i have a such table:
then i created classes:
class table_1 extends Zend_Db_Table_Abstract
{
protected $_name = 'table_1';
protected $_primary = 't1_id';
protected $_referenceMap = array(
'DepCard' => array(
'columns' => 't1_id',
'refTableClass' => 'table_2',
'refColumns' => 't2_t1'
),
'Select1' => array(
'columns' => array('t1_select1'),
'refTableClass' => 'Select_1'
),
'Select2' => array(
'columns' => array('t1_select2'),
'refTableClass' => 'Select_2'
)
);
}
class table_2 extends Zend_Db_Table_Abstract {
protected $_dependentTables = array('table_1');
}
class Select_1 extends Zend_Db_Table_Abstract {
protected $_dependentTables = array('table_1');
}
class Select_2 extends Zend_Db_Table_Abstract{
protected $_dependentTables = array('table_1');
}
then i want to:
$table_1 = new table_1();
$data = $table_1->fetchAll();
with all dependent tables.
is there any way to do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
查看
Zend_Db_Table
和Zend_Db_Table_Select
的代码表明这是不可能的。它始终仅在单个表上运行fetchAll
。Looking at
Zend_Db_Table
's andZend_Db_Table_Select
's code indicates that this is not possible. It always runsfetchAll
on the single table only.