扩展扩展 Zend_Db_Table_Row_Abstract 的类

发布于 2024-11-30 06:58:44 字数 964 浏览 1 评论 0原文

我们正在使用 Zend Framework 构建一个在线支付系统,并尝试将其设计为更容易添加新的支付系统。目前我们已经实现了 PayPal,但也许我们以后也想添加其他提供商。

我们有一个扩展 Zend_Db_Table_Row_Abstract 的 Payment 对象和一个扩展 Zend_Db_Table_Abstract 的 Payments 对象。 Payment 对象现在在其行中有 PayPal 特定数据,我们希望将其移动到另一个 PayPal 特定表。这使我们能够在付款表中拥有付款的一般数据,并在另一个表中拥有支付提供商的特定数据。

现在我们尝试创建一个扩展 Payment 的 PayPalPayment 类和一个扩展 Zend_Db_Table_Abstract 的 PayPalPayments 类。 PayPalPayments 指的是我们的新数据库表和新对象 PayPalPayment。我们现在要做的是:

$ppp = new PayPalPayments();
$p = $ppp->createRow();
//set a paypal specific property. setToken is defined in PayPalPayment
$p->setToken('lol');
//set a Payment general property. setStatus is defined in Payment
$p->setStatus('paid');
//write to database
$p->save();

但是,我们无法让它工作,因为 createRow 只会返回包含 PayPalPayment 表中的列的行。所以这会给出错误:

Specified column "pay_status" is not in the row

在 Zend 框架文档中找到了一些关于关系的内容,但这并不是我们真正想要的方式。以前有人尝试过这个吗?

问候, 拉尔斯

We are building an online payment system using Zend Framework and we try to design it to make it easier to add new payment systems. Currently we have an implementation for PayPal, but maybe we want to add other providers later too.

We have a Payment object that extends Zend_Db_Table_Row_Abstract and a Payments object extending Zend_Db_Table_Abstract. The Payment object now has PayPal specific data in its row which we want to move to a different, PayPal specific, table. This enables us to have general data for payments in the payments table and payment provider specific data in another.

Now we tried to make a class PayPalPayment extending Payment and a class PayPalPayments extending Zend_Db_Table_Abstract. The PayPalPayments refers to our new database table and the new object PayPalPayment. What we want to do now is:

$ppp = new PayPalPayments();
$p = $ppp->createRow();
//set a paypal specific property. setToken is defined in PayPalPayment
$p->setToken('lol');
//set a Payment general property. setStatus is defined in Payment
$p->setStatus('paid');
//write to database
$p->save();

However, we cannot get this to work since the createRow will only return a row with the columns in the PayPalPayment table. So this would give the error:

Specified column "pay_status" is not in the row

Found some things about relations in the Zend framework documentation, but that's not really how we want to do it. Anyone tried this before?

Regards,
Lars

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

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

发布评论

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

评论(1

甜宝宝 2024-12-07 06:58:44

您是否在 class PayPalPayments 中声明了默认的 $_rowClass = 'PayPalPayment'

Did you declare in class PayPalPayments that the default $_rowClass = 'PayPalPayment'?

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