数组到 Zend_Db_Table_Row zend 框架

发布于 2024-08-05 03:57:02 字数 256 浏览 9 评论 0原文

有没有一种方法可以自动从数组转换为 Zend_Db_Table_Row 或 Zend_Db_Table_Rowset?

从 Zend_Db_Table_Row 中你可以使用 toArray() 获取数组,但我想知道是否存在与此相反的东西?

到目前为止,我一直在实现一个函数 fill($data) ,它获取数组并设置 Zend_Db_Table_Row 的属性。

当然,数组键与 Zend_Db_Table_Row 属性相同。

谢谢!

is there a way of automatic converting from array to Zend_Db_Table_Row or Zend_Db_Table_Rowset?

Form Zend_Db_Table_Row you can get the array with toArray(), but I was wondering if there exits anything like opposite of that?

Till now I have been implementing a function fill($data) which took the array and than set the atributes of Zend_Db_Table_Row.

Of course array keys are the same as Zend_Db_Table_Row attributes.

Thanx!

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

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

发布评论

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

评论(2

坏尐絯 2024-08-12 03:57:03

我认为这应该可以解决问题:

$myRow = new Zend_Db_Table_Row(
    array(
        'data' => array( /* your array with data */  )
    )
);

因此,如果您为构造函数提供一个包含关键“数据”的配置数组,而该数组又包含一个包含数据的数组,那么您应该会很好。

有关详细信息,请查看 Zend 库中的 Zend_Db_Table_Row_Abstract。

I think this should do the trick:

$myRow = new Zend_Db_Table_Row(
    array(
        'data' => array( /* your array with data */  )
    )
);

So, if you provide the constructor with a config array that holds a key 'data' that in it's turn holds an array with the data, you should be good.

For more info look into Zend_Db_Table_Row_Abstract in your Zend library.

沫雨熙 2024-08-12 03:57:02

检查 Zend_Db_Table 的 fetchRow() 方法。在那里你可以找到它。我想你可以将数组提供给构造函数,如下所示:

$data = array(
        'table'   => $yourDbTableModel,
        'data'     => $yourArray,
        'readOnly' => $iGuessShouldBeZero,
        'stored'  => true
    );
$row = new Zend_Db_Table_Row($data);

Check the Zend_Db_Table's fetchRow() method. There you can find it. I guess you can feed the array to the constructor like this:

$data = array(
        'table'   => $yourDbTableModel,
        'data'     => $yourArray,
        'readOnly' => $iGuessShouldBeZero,
        'stored'  => true
    );
$row = new Zend_Db_Table_Row($data);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文