【问题标题】:Zend relationship - get the parent rowZend 关系 - 获取父行
【发布时间】:2011-09-10 21:16:54
【问题描述】:

我知道网络上有一些示例,但不适用于我的情况。

我有一个包含子类别的类别表。一个表“类别”,其 id_father 是父类别的 id。 我的配置如下:

Application_Model_DbTable_Category:

protected $_referenceMap = array(
    'Application_Model_DbTable_Category' => array(
        'columns'           => 'id_father',
        'refColumns'        => 'id',
        'refTableClass'     => 'Application_Model_DbTable_Category'
));

CategoryMapper(我不写最上面的代码,反正我检索到一个在 db 中有父类的 Category)

$row = $result->current(); 
echo $row->name;
$father = 'Non trovato';
$father = $row->findParentRow('Application_Model_DbTable_Category');
print_r($father);

这不会打印任何东西...我的代码有问题吗?谢谢你

【问题讨论】:

    标签: zend-framework zend-db


    【解决方案1】:

    您需要创建 Application_Model_DbTable_Category 类的实例

    $row = $result->current(); 
    echo $row->name;
    $father = 'Non trovato';
    $father = $row->findParentRow(new Application_Model_DbTable_Category());
    print_r($father);
    

    【讨论】:

    • 我爱你!谢谢!你能解释一下为什么在文档中他们总是传递一个字符串作为参数吗? :S
    • 它作为文档错误@zend then .
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-10-09
    • 2017-05-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多