View Full Version : Best Way To Approach SQL to Flash
dualpixel
11-09-2006, 02:28 PM
Hello All,
I would appreciate some suggestions on the best way of generating XML on the fly from SQL to then bring the XML into Flash and generate List items.
The SQL database will consist of a one to many relationship of brand to products and then each product will have an image that will need to be called.
Basically, the first step is getting this information into an XML format from the SQL database so any suggestions on how to do that or is PHP is the only way to generate XML on the fly?
buginajar
11-09-2006, 03:01 PM
Here is one way.
Create a webservice that takes in a brand name as an argument.
function getProducts(String brandName){}
Basically the webservice function will query the database and return an array of products.
In flash you can call a webservice. Assuming you program your webservice correctly, you will recieve an object/arry of products back for you to manupulate.
i.e
trace(products[2].imageName);
dualpixel
11-09-2006, 03:06 PM
So the webservice connector allows you to directly query the SQL?
Could you post an example of how this would connect with the database?
dualpixel
11-09-2006, 04:02 PM
Is there anyway possible to connect flash directly to SQL?
Or do you have to use some kind of server side script?
buginajar
11-10-2006, 01:14 AM
I wouldn't use the webservice connector, seems to be more problems than its worth, just code it out.
Are you familiar with creating web services?
If you can come up with a webservice somewhere, I can help you implement it. I made a simple webservice class that might help you out.
And, without flash remoting (not even sure if that does it, but it costs mucho money) i don't think there is an easier way.
Use PHP to create the XML on the fly. Using the XMLobject, but instead of calling an XML file, you'd call a php file, but the php would output like this
<?
// MAKE THE XML DOC
header("Content-Type: application/xml; charset=ISO-8859-1");
echo '<?xml version="1.0" encoding="iso-8859-1"?>' . "\n";
echo '<book>' . "\n";
for ($i=0; $i < count($titles); $i++) {
echo '<releasedate="' . $dates[$i] . '" title="' . $titles[$i] . '" bin ="' . $bins[$i] . '" author="' . $authors[$i] . '" />' . "\n";
}
echo '</book>';
?>
PHP courtesy of Flash Gordon.
dualpixel
11-10-2006, 01:07 PM
Thanks Cota, from my research over the past couple of days, it would seem that SQL -> PHP -> XML -> Flash and vise-versa is definately the best approach.
~DP
Let us know if you get stuck.
duncanhall
11-10-2006, 01:56 PM
Thanks Cota, from my research over the past couple of days, it would seem that SQL -> PHP -> XML -> Flash and vise-versa is definately the best approach.
~DP
Why not use http://www.amfphp.org and skip out the XML part altogether. Just use PHP to get flash 'talking' to to your database.
|
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.