【发布时间】:2011-07-28 13:18:09
【问题描述】:
我正在为 PHP 4.5、ZendAMF 使用 FB,并且我读到我不需要使用 HTTPService 来完成我想做的事情。
表结构:
people: {pID, pName}
departments: {deptID, deptName}
people_departments: {pID, deptName}
我有一个稍微复杂的 flex 脚本,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:Checkbox,但我没有 data 属性。 mx:Checkbox 可以,但我不能在我的项目中使用 mx:Checkbox 组件。
我将不胜感激。另外,有没有更好的方法来做到这一点?
【问题讨论】:
标签: php mysql apache-flex checkbox repeater