Fábio Antunes
Fábio Antunes

Reputation: 17164

How to update a MySql DB using Flex

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.

Upvotes: 2

Views: 3336

Answers (5)

Jon
Jon

Reputation: 4295

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

Upvotes: 1

ryanday
ryanday

Reputation: 2516

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.

Upvotes: 1

Adrian Pirvulescu
Adrian Pirvulescu

Reputation: 4340

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

Upvotes: 2

justinl
justinl

Reputation: 10538

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.

Upvotes: 2

stevedbrown
stevedbrown

Reputation: 8934

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.

Upvotes: 1

Related Questions