Saving form fields in a MySQL DB usinf Flex

时光毁灭记忆、已成空白 提交于 2019-12-08 12:37:27

问题


I have a MySQL database, and i created a DB and named it 'PERSONDB'. Within that DB, i have created a table and named it Person. This table has 3 fields. id,name,age.

Now i need to save some values from my flex website to the mySQL 'PERSONDB' that i created.

How can i do this in Flex (Flax builder 4.6)

Note: I have added 2 fields name and age, in the Flex project and when the user clicks on the Button i need those values to be saved in the DB. how can i do this.


回答1:


asSQL ( http://code.google.com/p/assql/ ) is a good approach to using mySQL. It allows for direct access to mySQL from any application either in AIR or web based. I use this pretty regularly in my coding so I don't have to write a Java or PHP as a back end unless there is a good reason to have a back end in place.

OK, here is the code I use:

    <assql:MySqlService id         ="DB"
                        hostname   ="localhost"
                        username   ="user"
                        password   ="password"
                        database   ="db"
                        autoConnect="true"
                        connect    ="handleConnected(event)"
                        sqlError   ="handleError(event)"/>


        private function getSelectedData() : void
        {
            DB.send("SELECT * from table WHERE number = '" + number.text + "'");
        }

That's all there is too it. The top part sets up the connection and is in the section of the code. The rest is in the part (ActionScript). Of course, it can be done in straight ActionScript as well, but this solution used MXML.



来源:https://stackoverflow.com/questions/11134980/saving-form-fields-in-a-mysql-db-usinf-flex

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