Zend Framework 和嵌套集

发布于 2024-12-18 17:13:58 字数 1070 浏览 2 评论 0原文

我们目前正在基于 Zend Framework 开发自己的 ShopProducts Feedmanager。 在此 feedmanager 中,您可以管理多个要创建并发送到不同位置的 feed。 每个提要都有 n 个字段,这些字段在当前版本中仅存在于一个级别中。 现在我们想将其更改为多级版本,我们有父字段和子字段。

我们不想重新发明轮子,所以我们想使用开发的类或助手。

我找到了 F. Pietka 的班级。 https://github.com/fpietka/Zend-Nested-Set 我尝试在我们的系统中使用这个助手,但没有成功。

我编写了以下行来使用该类:

$oNested = new NestedSet_Model();

我收到以下错误消息:

致命错误:调用未定义的方法 NestedSet_Model::getDbTable() D:\xampp\htdocs\feedmanager_alpha\application\classes\NestedSet.class.php 第75行

Peitka 的 NestedSet 帮助程序的自述文件中,它说 ZendLibrary 需要位于包含路径中。

我想我是用以下几行做到的:

define("ROOTPATH", realpath("../"));
define("LIBPATH", ROOTPATH . DIRECTORY_SEPARATOR . 'library' . DIRECTORY_SEPARATOR);

// Ensure library/ is on include_path
set_include_path(
    implode(PATH_SEPARATOR,
        array(
            realpath(LIBPATH)
        )
    )
);

我是否正确设置了包含路径? 我的情况可能是什么问题? 嵌套集是创建父子模型的最佳方式吗?

we`re currently developing our own Feedmanager for ShopProducts based on Zend Framework.
In this feedmanager you can manage several feeds, to be created and sent to different locations.
Each feed has n-fields which are in the current version only in one level.
Now we want to change it to a multilevel version, we we have parentfields and childfields.

We dont want to reinvent the wheel, so we would like to use a developed class or helper.

I found the class of F. Pietka.
https://github.com/fpietka/Zend-Nested-Set
I tried to use this helper in our system, but had no success.

I wrote the following line, to use the class:

$oNested = new NestedSet_Model();

I got the following error message:

Fatal error: Call to undefined method NestedSet_Model::getDbTable() in
D:\xampp\htdocs\feedmanager_alpha\application\classes\NestedSet.class.php
on line 75

In the readme of Peitka`s NestedSet helper it says that the ZendLibrary needs to be in the include path.

I think I did this with the following lines:

define("ROOTPATH", realpath("../"));
define("LIBPATH", ROOTPATH . DIRECTORY_SEPARATOR . 'library' . DIRECTORY_SEPARATOR);

// Ensure library/ is on include_path
set_include_path(
    implode(PATH_SEPARATOR,
        array(
            realpath(LIBPATH)
        )
    )
);

Did I set the include path correctly?
What could be the problem in my case?
Is a nested-set the best way to create the parent-child-model?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(3

记忆里有你的影子 2024-12-25 17:13:59

我强烈建议你不要使用这个类,因为它显然是一个 WIP。但是,如果您想避免此错误,只需删除 __construct() 方法并手动调用 setDb() 和 setTableName() 即可。

例子:

$model = new NestedSet_Model();
$model->setDb(Zend_Db_Table::getDefaultAdapter());
$model->setTableName('table_name');

I would strongly advise you not to use this class, because it's clearly a WIP. However, if you want to circumvent this error, you can just delete the __construct() method and call the setDb() and setTableName() by hand.

Example:

$model = new NestedSet_Model();
$model->setDb(Zend_Db_Table::getDefaultAdapter());
$model->setTableName('table_name');
橘亓 2024-12-25 17:13:59
class NestedSet extends Zend_Db_Table
{
    protected $_name = 't_nested_set_mkb_10';

    public function set(){
        $model = new NestedSet_Model();
        $model->setDb(Zend_Db_Table::getDefaultAdapter());
        $model->setTableName('t_nested_set_mkb_10');
    }
}
class NestedSet extends Zend_Db_Table
{
    protected $_name = 't_nested_set_mkb_10';

    public function set(){
        $model = new NestedSet_Model();
        $model->setDb(Zend_Db_Table::getDefaultAdapter());
        $model->setTableName('t_nested_set_mkb_10');
    }
}
我喜欢麦丽素 2024-12-25 17:13:59

早就该了,但我更新了 https://github.com/fpietka/Zend-Nested-Set (即使有单元测试)。

随意创建问题!

It was long overdue, but I updated https://github.com/fpietka/Zend-Nested-Set (even with unit tests).

Feel free to create issues!

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