Flex 和 Zend_AMF:如何将 Flex arrayCollection 从 Flex 获取到 PHP 中?
我目前在 Flex 中有一个 arrayCollection,我想将其发送到 PHP (Zend_AMF)。根据 Zend_AMF wiki,直接发送 arrayCollection 将强制 Zend_AMF 将 arrayCollection 转换为对象,这是不好的。我宁愿拥有一系列我的模型。
我认为最好的方法是将 arrayCollection 转换为 Flex 中的数组,然后将其发送过来。这是真的吗?如果是,我该如何在 Flex 3 中做到这一点?
如果您有更好的推荐,也将不胜感激。
感谢您的关注!
I currently have an arrayCollection in Flex and I want to sent it to PHP (Zend_AMF). According to the Zend_AMF wiki, sending an arrayCollection over directly will force Zend_AMF to cast the arrayCollection as an object which is no good. I'd rather have an array of my models.
I assume the best way would be to convert the arrayCollection to an array in flex and then send it over. Is this true, and if so how would I do that in Flex 3?
If you have a better recommendation, that would be appreciated as well.
Thanks for looking!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
实际上,您可以在 PHP 端创建 ArrayCollection 类型并直接通过 AMF 发送本机 ArrayCollection 对象。
这是我的一些有效的 php 代码。 的文件中
将其保存在名为ArrayCollection.php
要在 php 端使用它,请在您的 php 项目中包含 ArrayCollection.php ,调用它的语法如下所示:
如果您想访问组成 ArrayCollection 的数组,您可以 在 Flex 端,
您可以通过 Zend AMF 将数组集合直接传递到服务器。在我的一个项目中,我有许多包含 ArrayCollections 的值对象,它们在 PHP 方面工作得很好。所以这是可以做到的。
如果您绝对无法在 PHP 中使用 ArrayCollection,您可以在 Actionscript 中将数组作为 ArrayCollection 的“源”属性进行访问。代码在 actionscript 中看起来像这样:
myArray 现在将是 ArrayCollection myAC 中的对象的数组。
希望这有帮助。如果您还有其他问题和/或有代码示例,请告诉我。
我也花了一点时间才弄清楚这个问题。
Actually, you can create an ArrayCollection type on the PHP side and send native ArrayCollection objects directly over AMF.
Here is some php code I have that works. Save this in a file called
ArrayCollection.php
To use this on the php side include the ArrayCollection.php in your php project and the syntax to call it looks something like this:
and if you want to access the array that composes the ArrayCollection you can do this
On the Flex side you can pass Array Collections directly to the server over Zend AMF. In one of my projects I have many value objects that have ArrayCollections in them and they work just fine on the PHP side. So it can be done.
If you absolutely can't get the ArrayCollection working in PHP you can just access the array as the "source" property of the ArrayCollection in Actionscript. The code looks something like this in actionscript:
myArray will now be an Array of the objects in the ArrayCollection myAC.
Hope this helps. If you have further questions and/or have a code sample let me know.
It took me a bit to figure this one out too.