Got a real challenge for you. I am trying to use RemoteObject and AMF to get some data out of my database. Two of the functions in my PHP class work great, count and gethalf. But the gethalfcomps function always gets me the following error:
[RPC Fault faultString="Channel disconnected" faultCode="Client.Error.DeliveryInDoubt" faultDetail="Channel disconnected before an acknowledgement was received"] How two of the functions operate correctly and one does not is baffling to me. Any even random thoughts on possibilities would be greatly appreciated. The function that I am struggling with is getHalfComps. Here is the PHP code: <?php /** * README for sample service * * This generated sample service contains functions that illustrate typical service operations. * Use these functions as a starting point for creating your own service implementation. Modify the * function signatures, references to the database, and implementation according to your needs. * Delete the functions that you do not use. * * Save your changes and return to Flash Builder. In Flash Builder Data/Services View, refresh * the service. Then drag service operations onto user interface components in Design View. For * example, drag the getAllItems() operation onto a DataGrid. * * This code is for prototyping only. * * Authenticate the user prior to allowing them to call these methods. You can find more * information at http://www.adobe.com/go/flex_security * */ define("DATABASE_SERVER", "localhost"); define("DATABASE_PORT", "3306"); define("DATABASE_USERNAME", {myusername}); define("DATABASE_PASSWORD", {mypassword}); define("DATABASE_NAME", {mydatabasename}); class HalfService { /** * The constructor initializes the connection to database. Everytime a request is * received by Zend AMF, an instance of the service class is created and then the * requested method is invoked. */ public function __construct() { try{ $this->pdo = new PDO('mysql:host='.DATABASE_SERVER.';port='.DATABASE_PORT.';dbname='.DATABASE_NAME, DATABASE_USERNAME, DATABASE_PASSWORD); $this->pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $this->pdo->setAttribute( PDO::ATTR_EMULATE_PREPARES, false ); } catch(PDOException $e){ $error = "Connection failed: " . $e->getMessage(); } } /** * Returns rows from the table. * * Add authroization or any logical checks for secure access to your data * * @return array */ public function getHalf($itemst, $itemci, $itempc, $itempbmin, $itempbmax, $itemapmin, $itemapmax, $itemprmin, $itemprmax, $itemprofit, $itemdom, $itembu, $itemsd, $itemsu, $itempt, $itembeds, $itembaths, $itemsqft, $itemdi) { $itemst2 = [$itemst]; $itempc2 = [$itempc]; $itempbmin2 = [$itempbmin]; $itempbmax2 = [$itempbmax]; $itemapmin2 = [$itemapmin]; $itemapmax2 = [$itemapmax]; $itemprmin2 = [$itemprmin]; $itemprmax2 = [$itemprmax]; $itemprofit2 = [$itemprofit]; $itemdom2 = [$itemdom]; $itembu2 = [$itembu]; $itembeds2 = [$itembeds]; $itembaths2 = [$itembaths]; $itemsqft2 = [$itemsqft]; $itemdi2 = [$itemdi]; $container = explode(',', $itempt); $bindStr = implode(",", array_map(function($val) { return "?"; }, $container)); $queryString = "SELECT uniqueID, address, appliances, architecturalStyle, area, areasInterior, auctionCompanyName, auctionDate, auctionTime, averagePrice, basement, basementDescription, bathsFull, bathsHalf, bathsTotal, beds, built, " ."city, cool, countyOrParish, dateClosed, dateListed, disclosures, dom, equipment, exterior, exteriorAmenities, fireplace, fireplaceDescription, foundation, fuel, garage, hasComps, " ."heat, interior, latitude, levels, longitude, lotInformation, lotSize, listAgentFullName, listOfficeName, mandatoryFee, mandatoryFeeIncludes, mandatoryFeePaid, masterBedroomDescription, " ."modifiedDT, MLSName, MLSNum, perBelow, porch, price, profit, propCount, propDescription, propType, schoolDistrict, semiAnnualPropertyTaxAmt, sqFtMain, sqFtTotal, " ."state, status, subdivision, taxYear, totalNumOfAcres, township, url, utilityOptions, utilityPrimSewageDisp, utilityPrimWaterSource, zipcode FROM half WHERE (state=?) AND (propCount >= ?) AND " ."(perBelow >= ?) AND (perBelow <= ?) AND (averagePrice >= ?) AND (averagePrice <= ?) AND (price >= ?) AND (price <= ?) AND " ."(profit >= ?) AND ((UNIX_TIMESTAMP(NOW())*1000 - dateListed)/86400000 <= ?) AND (built <= ?) AND (beds >= ?) AND (bathsTotal >= ?) AND (sqFtTotal >= ?) AND (propType IN ({$bindStr})) AND (? IS NULL OR disclosures = ?)"; $params = array(); $params = array_values(array_merge($itemst2,$itempc2, $itempbmin2, $itempbmax2, $itemapmin2, $itemapmax2, $itemprmin2, $itemprmax2, $itemprofit2, $itemdom2, $itembu2, $itembeds2, $itembaths2, $itemsqft2, $container, $itemdi2, $itemdi2)); if ($itemsd == NULL && $itemsu == NULL) { $itemci2 = ['%'.$itemci.'%']; $queryString = $queryString." AND (address LIKE ? OR MLSNum LIKE ? OR city LIKE ?)"; $params = array_values(array_merge($params,$itemci2,$itemci2,$itemci2)); $stmt = $this->pdo->prepare($queryString); } else if ($itemsd != NULL && $itemsu != NULL) { $itemci2 = ['%'.$itemci.'%']; $itemsd2 = ['%'.$itemsd.'%']; $itemsu2 = ['%'.$itemsu.'%']; $queryString = $queryString." AND (schoolDistrict LIKE ?) AND (subdivision LIKE ?) AND (address LIKE ? OR MLSNum LIKE ? OR city LIKE ?)"; $params = array_values(array_merge($params,$itemsd2,$itemsu2,$itemci2,$itemci2,$itemci2)); $stmt = $this->pdo->prepare($queryString); } else if ($itemsd != NULL && $itemsu == NULL) { $itemci2 = ['%'.$itemci.'%']; $itemsd2 = ['%'.$itemsd.'%']; $queryString = $queryString." AND (schoolDistrict LIKE ?) AND (address LIKE ? OR MLSNum LIKE ? OR city LIKE ?)"; $params = array_values(array_merge($params,$itemsd2,$itemci2,$itemci2,$itemci2)); $stmt = $this->pdo->prepare($queryString); } else if ($itemsd == NULL && $itemsu != NULL) { $itemci2 = ['%'.$itemci.'%']; $itemsu2 = ['%'.$itemsu.'%']; $queryString = $queryString." AND (subdivision LIKE ?) AND (address LIKE ? OR MLSNum LIKE ? OR city LIKE ?)"; $params = array_values(array_merge($params,$itemsu2,$itemci2,$itemci2,$itemci2)); $stmt = $this->pdo->prepare($queryString); } $stmt->execute($params); $result = $stmt->fetchAll(PDO::FETCH_OBJ); $this->pdo = null; return $result; } /** * Returns rows from the comp table * * Add authorization or any logical checks for secure access to your data * * * @return stdClass */ public function getHalfComps($itemst, $itemmls, $itemouid) { $itemst2 = [$itemst]; $itemmls2 = [$itemmls]; $itemouid2 = [$itemouid]; $queryString = "SELECT origUniqueID, uniqueID, address, appliances, architecturalStyle, area, areasInterior, auctionCompanyName, auctionDate, auctionTime, basement, basementDescription, bathsFull, bathsHalf, bathsTotal, beds, built, " ."city, cool, countyOrParish, dateClosed, dateListed, disclosures, dom, equipment, exterior, exteriorAmenities, fireplace, fireplaceDescription, foundation, fuel, garage, " ."heat, interior, latitude, levels, longitude, lotInformation, lotSize, listAgentFullName, listOfficeName, mandatoryFee, mandatoryFeeIncludes, mandatoryFeePaid, masterBedroomDescription, " ."modifiedDT, MLSName, MLSNum, porch, price, propDescription, propType, schoolDistrict, semiAnnualPropertyTaxAmt, sqFtMain, sqFtTotal, " ."state, status, subdivision, taxYear, totalNumOfAcres, township, url, utilityOptions, utilityPrimSewageDisp, utilityPrimWaterSource, zipcode FROM " ."halfcomp WHERE state = ? AND MLSName = ? AND origUniqueID = ?"; $params = array(); $params = array_values(array_merge($itemst2, $itemmls2, $itemouid2)); $stmt = $this->pdo->prepare($queryString); $stmt->execute($params); $result = $stmt->fetchAll(PDO::FETCH_OBJ); $this->pdo = null; return $result; } /** * Counts records in the table * * Add authorization or any logical checks for secure access to your data * * */ public function count($itemst, $itemci, $itempc, $itempbmin, $itempbmax, $itemapmin, $itemapmax, $itemprmin, $itemprmax, $itemprofit, $itemdom, $itembu, $itemsd, $itemsu, $itempt, $itembeds, $itembaths, $itemsqft, $itemdi) { $itemst2 = [$itemst]; $itempc2 = [$itempc]; $itempbmin2 = [$itempbmin]; $itempbmax2 = [$itempbmax]; $itemapmin2 = [$itemapmin]; $itemapmax2 = [$itemapmax]; $itemprmin2 = [$itemprmin]; $itemprmax2 = [$itemprmax]; $itemprofit2 = [$itemprofit]; $itemdom2 = [$itemdom]; $itembu2 = [$itembu]; $itembeds2 = [$itembeds]; $itembaths2 = [$itembaths]; $itemsqft2 = [$itemsqft]; $itemdi2 = [$itemdi]; $container = explode(',', $itempt); $bindStr = implode(",", array_map(function($val) { return "?"; }, $container)); $queryString = "SELECT COUNT(*) AS COUNT FROM half WHERE (state=?) AND (propCount >= ?) AND " ."(perBelow >= ?) AND (perBelow <= ?) AND (averagePrice >= ?) AND (averagePrice <= ?) AND (price >= ?) AND (price <= ?) AND " ."(profit >= ?) AND ((UNIX_TIMESTAMP(NOW())*1000 - dateListed)/86400000 <= ?) AND (built <= ?) AND (beds >= ?) AND (bathsTotal >= ?) AND (sqFtTotal >= ?) AND (propType IN ({$bindStr})) AND (? IS NULL OR disclosures = ?)"; $params = array(); $params = array_values(array_merge($itemst2,$itempc2, $itempbmin2, $itempbmax2, $itemapmin2, $itemapmax2, $itemprmin2, $itemprmax2, $itemprofit2, $itemdom2, $itembu2, $itembeds2, $itembaths2, $itemsqft2, $container, $itemdi2, $itemdi2)); if ($itemsd == NULL && $itemsu == NULL) { $itemci2 = ['%'.$itemci.'%']; $queryString = $queryString." AND (address LIKE ? OR MLSNum LIKE ? OR city LIKE ?)"; $params = array_values(array_merge($params,$itemci2,$itemci2,$itemci2)); $stmt = $this->pdo->prepare($queryString); } else if ($itemsd != NULL && $itemsu != NULL) { $itemci2 = ['%'.$itemci.'%']; $itemsd2 = ['%'.$itemsd.'%']; $itemsu2 = ['%'.$itemsu.'%']; $queryString = $queryString." AND (schoolDistrict LIKE ?) AND (subdivision LIKE ?) AND (address LIKE ? OR MLSNum LIKE ? OR city LIKE ?)"; $params = array_values(array_merge($params,$itemsd2,$itemsu2,$itemci2,$itemci2,$itemci2)); $stmt = $this->pdo->prepare($queryString); } else if ($itemsd != NULL && $itemsu == NULL) { $itemci2 = ['%'.$itemci.'%']; $itemsd2 = ['%'.$itemsd.'%']; $queryString = $queryString." AND (schoolDistrict LIKE ?) AND (address LIKE ? OR MLSNum LIKE ? OR city LIKE ?)"; $params = array_values(array_merge($params,$itemsd2,$itemci2,$itemci2,$itemci2)); $stmt = $this->pdo->prepare($queryString); } else if ($itemsd == NULL && $itemsu != NULL) { $itemci2 = ['%'.$itemci.'%']; $itemsu2 = ['%'.$itemsu.'%']; $queryString = $queryString." AND (subdivision LIKE ?) AND (address LIKE ? OR MLSNum LIKE ? OR city LIKE ?)"; $params = array_values(array_merge($params,$itemsu2,$itemci2,$itemci2,$itemci2)); $stmt = $this->pdo->prepare($queryString); } $stmt->execute($params); $result = $stmt->fetchAll(PDO::FETCH_ASSOC); $this->pdo = null; $rec_count = $result[0]['COUNT']; if ($rec_count > 200) { $rec_count = 0; } else { $rec_count = 1; } return $rec_count; } } ?> -- Sent from: http://apache-flex-users.2333346.n4.nabble.com/