How to update a MySql DB using Flex

瘦欲@ 提交于 2019-12-04 04:53:59

问题


Just got developing with Flex, and i like it.

I've done some simple apps to get the felling of it, nothing involving updating a file or a database.

I wanted help, how to do a query to a MySql DB from a Flex application (thats gonna be running in a web server).

I didn't saw any duplicated questions, sorry if any exists, just point me to it.

EDIT:

Using PHP to do the query on the server.


回答1:


While I've never done this myself I have read and watched tutorials about it. The tutorial can be found here and the one in particular is labeled "Integrating Flex with PHP using XML" and is at the bottom of the page.

http://www.adobe.com/devnet/flex/videotraining/

It basically outlines how to use Flex's HTTPService to interact with a PHP script. This PHP script can be used to communicate directly between your flash application and your mysql database using GET and POST vars.




回答2:


From flex you cannot access directly a database on a server. For that you need a webservice on the database server which will act as a middle-tool between your Flex app and the database.

So practically you will have on the webservice some webmethods which will do the queries for flex and return the results to it.

As a example: You have a webmethod called loginUser(username,passwprd):bool. You call this method from flex, the method checks the database and returns a Boolean value representing the success result of the login.

You can create webservices for Flex apps with php c# java and so on... just need to google about them. :)


Adrian




回答3:


Flex applications are not run on the server, they are run on the client. You do not want them accessing your database directly, and thusly, they generally can't.

The DB update should be done in the server side code/language.




回答4:


Take a look at AMFPHP also. This is a pretty good way to serialize data between PHP and your Flex front end. AMFPHP also has built in methods for handling user sessions to maintain security. I use it at work to let our Flex app access our back end database.

As far as file access, I think you need to create an AIR application to have access to the File class. Flex isn't allowed access to the local file system for security purposes.




回答5:


You could think about using a restful service if your using PHP, as this wouldn't need you to learn complicated web services and SOAP stuff. Put your requests in the query string of the php file i.e.

www.myserver.com/getproductprice.php?id=23&quanity=2312

then all you need to do is get the values from the url in php

id = $_GET['id'];  //(my php is not too good!!!)
id = $_GET['quanity'];

then go off and do you db query in php. this could then return you either text or xml. It's simpler model to get going it your just starting out.

hope this helps



来源:https://stackoverflow.com/questions/1256644/how-to-update-a-mysql-db-using-flex

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!