問(wèn)題描述
我有一個(gè) MySQL 數(shù)據(jù)庫(kù),我創(chuàng)建了一個(gè)數(shù)據(jù)庫(kù)并將其命名為PERSONDB".在該數(shù)據(jù)庫(kù)中,我創(chuàng)建了一個(gè)表并將其命名為 Person
.該表有 3 個(gè)字段.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
.
現(xiàn)在我需要將一些值從我的 flex 網(wǎng)站保存到我創(chuàng)建的 mySQL 'PERSONDB'.
Now i need to save some values from my flex website to the mySQL 'PERSONDB' that i created.
我如何在 Flex (Flax builder 4.6) 中執(zhí)行此操作
How can i do this in Flex (Flax builder 4.6)
注意:我在 Flex 項(xiàng)目中添加了 2 個(gè)字段名稱和年齡,當(dāng)用戶單擊按鈕時(shí),我需要將這些值保存在數(shù)據(jù)庫(kù)中.我該怎么做.
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 的任何應(yīng)用程序直接訪問(wèn) mySQL.我在編碼中經(jīng)常使用它,因此我不必編寫 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 + "'");
}
僅此而已.頂部設(shè)置連接,位于代碼部分.其余部分在 (ActionScript) 部分.當(dāng)然,也可以直接在 ActionScript 中完成,但是這個(gè)解決方案使用了 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.
這篇關(guān)于使用 Flex 將表單字段保存在 MySQL 數(shù)據(jù)庫(kù)中的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!