在MySQL DB usinf Flex中保存表单字段 [英] Saving form fields in a MySQL DB usinf Flex

查看:110
本文介绍了在MySQL DB usinf Flex中保存表单字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个MySQL数据库,我创建了一个数据库并将其命名为"PERSONDB".在该数据库中,我创建了一个表并将其命名为Person.该表具有3个字段. id,name,age.

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.

现在,我需要将一些值从我的flex网站保存到我创建的mySQL'PERSONDB'中.

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

我该如何在Flex(亚麻构建器4.6)中做到这一点

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

注意:我在Flex项目中添加了两个字段名称和年龄,当用户单击Button时,我需要将这些值保存在数据库中.我该怎么办.

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.

推荐答案

asSQL( http://code .google.com/p/assql/)是使用mySQL的一种好方法.它允许从AIR或基于Web的任何应用程序直接访问mySQL.我在编码中经常使用此代码,因此除非有充分的理由将后端安装到位,否则不必写Java或PHP作为后端.

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 + "'");
        }

这就是全部.顶部设置连接,位于代码部分.其余部分在(ActionScript)部分中.当然,它也可以直接在ActionScript中完成,但是此解决方案使用了MXML.

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.

这篇关于在MySQL DB usinf Flex中保存表单字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆