我使用PHP的PHP 4.5,ZendAMF,我讀了我不需要使用HTTPService來執行我想要的操作。如何將Flex複選框數組發送到mysql服務器?
表結構:
people: {pID, pName}
departments: {deptID, deptName}
people_departments: {pID, deptName}
我有一個稍微複雜的柔性腳本,People.mxml。在PersonAdd狀態下,我有一個將用於發送數據到mysql服務器的表單。在這種形式下,我有一個轉發器,它將爲我的數據庫中的每個部門創建一個複選框。當我點擊添加按鈕時,我想要插入數據到people
和people_departments
表中。
直放站代碼:
<mx:HBox>
<mx:Repeater id="checkBoxRepeater"
dataProvider="{getDepartmentsResult.lastResult}">
<s:CheckBox id="deptCB"
label="{checkBoxRepeater.currentItem.deptName}"/>
</mx:Repeater>
</mx:HBox>
在我peopleService.php文件,我將有功能createPerson(People $item,$deptArray)
和函數裏,我會執行兩個SQL查詢。一個查詢會將數據插入People表中,另一個將數據插入到people_departments中,people_departments.pID
=新插入的人的ID。
如您所見,在上面的Repeater代碼中,複選框作爲屬性標籤。但是,當我將dept_Array(類型ArrayCollection)發送到服務器時,前者需要包含deptID。我該怎麼做?
這是我如何創建People.mxml的dept_Array發送到服務器:
protected function button_clickHandler(event:MouseEvent):void
{
var dept_array:Array=[];
var idx:int;
var getDepts_array:ArrayCollection=new ArrayCollection;
getDepts_array=getDepartmentsResult.lastResult as ArrayCollection;
var len:int=getDepts_array.length;
for (idx=0; idx < len; idx++)
{
if (deptCB[idx].selected)
{
dept_array.push(deptCB[idx].label); //here I need to be able to push the ID of selected department.
}
}
}
[編輯]我使用的是S:複選框,我沒有數據屬性。 MX:複選框沒有,但我不能在我的項目中使用MX:複選框組件。
我將不勝感激任何幫助。另外,是否有更好的方法來做到這一點?
這是行不通的,因爲首先,我的表中沒有'deptSelected'字段,其次,'selected'是一個布爾屬性。 我最終所做的就是像往常一樣激活文檔,並仔細檢查整個列表。我發現一個屬性可以接受一個字符串,並且我調整了一下,並使用'automationName'屬性來完成我想要做的事情。 – shailenTJ
'
' – shailenTJ