数组到 Zend_Db_Table_Row zend 框架
有没有一种方法可以自动从数组转换为 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为这应该可以解决问题:
因此,如果您为构造函数提供一个包含关键“数据”的配置数组,而该数组又包含一个包含数据的数组,那么您应该会很好。
有关详细信息,请查看 Zend 库中的 Zend_Db_Table_Row_Abstract。
I think this should do the trick:
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.
检查 Zend_Db_Table 的 fetchRow() 方法。在那里你可以找到它。我想你可以将数组提供给构造函数,如下所示:
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: