Hello guys,
I'm trying to access a record from a table in the database to check if exists to select a checkBox.
Here are my codes so far.
This is the php code:
public function mpiIICheckIfExist($item) {
$stmt = mysqli_prepare($this->connection,
"SELECT mpiIIId
FROM $this->wo2mpi2ii
WHERE wo2mpiId = ? AND mpiIIId = ?
LIMIT 1"
);
$this->throwExceptionOnError();
mysqli_stmt_bind_param($stmt, 'ii', $item->wo2mpiId, $item->mpiIIId);
$this->throwExceptionOnError();
mysqli_stmt_execute($stmt);
$this->throwExceptionOnError();
$rows = array();
mysqli_stmt_bind_result($stmt, $row->mpiIIId);
while (mysqli_stmt_fetch($stmt)) {
$rows[] = $row;
$row = new stdClass();
mysqli_stmt_bind_result($stmt, $row->mpiIIId);
}
mysqli_stmt_free_result($stmt);
mysqli_close($this->connection);
return $rows;
}
When I test the code in Flash Builder like this {wo2mpiId:1, mpiIIId:1} I get wha I expect "mpiIIId = 1"
My problem is that I can access this variable the way I need to.
Here is my mxml file.
protectedfunction getIItems(event:FlexEvent):void {
getMpiII.token = mpiService.getMpiIndividualItems(mpiItemId);
getMpiII.addEventListener(ResultEvent.RESULT, genItems);
}
protectedfunction genItems(event:ResultEvent):void {
mpiVO.wo2mpiId = mpiId;
for (var i:int = 0; i < getMpiII.lastResult.length; i++) {
iBox = new spark.components.CheckBox();
iBox.id = getMpiII.lastResult[i].id;
// ***************** PROBLEM SECTION -- I Trying to do an if statement here but I can't get the return value to compare
mpiVO.mpiIIId = int(iBox.id);
//trace(mpiVO.wo2mpiId); // expected value - OK
//trace(mpiVO.mpiIIId); // expected value - OK
existMpiII.token = mpiService.mpiIICheckIfExist(mpiVO);
trace(existMpiII.lastResult[0].mpiIIId); // NOTHING HERE
// ***************** END PROBLEM SECTION
iBox.label = getMpiII.lastResult[i].individualItem;
//iBox.addEventListener(MouseEvent.CLICK, checkboxHandler);
iFormContent.addElement(iBox);
}
}
<fx:Declarations>
<s:CallResponder id="existMpiII" result="existMpiII.lastResult"/>
<s:CallResponder id="getMpiII"/>
<s:CallResponder id="createMpiII"/>
<wampiservice:WampiService id="mpiService" showBusyCursor="true"/>
</fx:Declarations>
Please help, if need more codes let me know.
Thank you, Robert