坚持 zend_db_table +加入

发布于 2024-11-26 13:20:37 字数 1155 浏览 7 评论 0原文

尝试了解如何使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

稚然 2024-12-03 13:20:37

查看 Zend_Db_TableZend_Db_Table_Select 的代码表明这是不可能的。它始终仅在单个表上运行 fetchAll

Looking at Zend_Db_Table's and Zend_Db_Table_Select's code indicates that this is not possible. It always runs fetchAll on the single table only.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文