That's why, when i had time; i started to develop a class which works with a specific php file. Currently codename of the class is EasyReq :p
in this post; i'll introduce EasyReq:
What is EasyReq ??
- it's a class based on mx.rpc.http.mxml.HTTPService . It works with specific php files (any_all.php , any_save.php , any_load.php maybe etc)
What does EasyReq do ??
- You tell EasyReq, what you want to fetch from which table, which order and what conditions. Than it processes your requests; prepare request object and sends the request to the server. In the server side; a php file accepts the request. Parses and creates the sufficient sql query. It also sends the query to database and return the result in a proper XML format to the user.
What is the advantage of EasyReq ??
- By easy request, you wont have to write many php files for your mysql database fetch-put operations. You will just have to create an EasyReq object, say it what your want...
AIM:?? to move everything possible to MXML side in an "efficient" way...
Where to download ??
Currently; there is no release; so you can not. But as soon as i reach some good point, i will release. I'm planning to release it in Abode Flex Exchange if possible...
How much??
It will be free and of course open source.Actually i will as for donations :) since i am just a sophomore who needs money to continue education..
Let's give some examples and finish this post... (to go on working on EasyReq)
:: Condition: i have two tables, chats, and insanlar (means peole in turkish) ; and want to get all posts of people who are in the insanlar table.i also want to rename fields to reduce the xml size. in normal case; you will have to write a php file which runs an sql and returns the xml result , but in a static way...when you want to chance sth. it would mean retyping the php file... let's see how much easy doing this with EasyReq:
<Yigit:EasyReq id="den" var_name="cocuk" url="http://localhost/flex/any_all.php" method="GET" result="{tmp()}"> <!-- i want all elements to be named as cocuk in the returning xml-->now, lets see the sql query created on the server:
<Yigit:vars>
<mx:XMLList> <!-- i could not find a way to get rid of these YET--><table name="insanlar" as="i"/></mx:XMLList>
<table name="chats" as="c"/> <!--you can rename your tables and use old or new names -->
<wanted name="i.ad"/>
<wanted name="i.soyad" as="soyad"/>
<order name="c.sender" way="-"/> <!-- shortcut to say descending ,also DESC can be used-->
<cond exp="c.sender = i.ad"/> <!-- add condition, you can add as many as you want-->
</Yigit:vars>
</Yigit:EasyReq>
SELECT i.ad AS ad , i.soyad AS soyad2 , c.sender AS soyad FROM insanlar AS i , chats AS c WHERE 1 AND (c.sender=i.ad ) ORDER BY c.sender DESC
and let's see the returning xml:
<answer result="1"><cocukS count="5"><cocuk text="oogfsdogfsd" ad="yigit" soyad="cacasadas" /><cocuk text="oogfsdogfsddsadsa" ad="yigit" soyad="cacasadas" /><cocuk text="fdfdaf" ad="yigit" soyad="cacasadas" /><cocuk text="fdsafdsa" ad="yigit" soyad="cacasadas" /><cocuk text="hadi bea" ad="yigit" soyad="cacasadas" /></cocukS></answer>
and finally see how we can use the result :
<mx:DataGrid x="10" y="46" dataProvider="{den.lastResult.answer.cocukS.cocuk}" >
<mx:columns>
<mx:DataGridColumn headerText="Ad" dataField="ad"/>
<mx:DataGridColumn headerText="Soyad" dataField="soyad"/>
<mx:DataGridColumn headerText="Metin" dataField="text"/>
</mx:columns>
</mx:DataGrid>
At the beginning of my conclusion; i want to say sorry for the bad example....
By the help of EasyReq , i want to let the community get rid of writing many many php files.. Currently; EasyReq can:
- fetch data from diffrent tables
- rename returning xml
- return number of result
- understand conditions
- and some more...
No comments:
Post a Comment