我使用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