if (mysql_num_rows($passInfo) > 0) { $passInfo = mysql_fetch_array($passInfo, MYSQL_ASSOC); if ($data['pid'] == $passInfo['aid']) { $passInfo['carpoolpath'] = json_decode($passInfo['carpoolpath'], true); $reCarpoolPath = json_encode($passInfo['carpoolpath'][$data['carpoolidx']]); // to client str // {"passenger":{"Name": "a", "CurPoint": 1, "Path": 1}} $clientStr = '{"passenger":{"Name": "' . $passInfo['name'] . '", "CurPoint": ' . $passInfo['curpoint'] . ', "Path": ' . $reCarpoolPath . '}}'; echo $clientStr; } } } } else { // Get necessary data from db // function GetneceData($did, $pids, $onlyPath) $neceData = GetneceData($data['did'], $data['pids'], $data['carpoolidx']); // first update driver current point UpdateCurrentPoint($data['did'], $data['curpoint']); // get target point $targetPoint = GetTargetPoint($neceData['driverPath'], $neceData['points']); // determine target point owner if get in car or get out off car $calResult = DetResult($targetPoint); // get each passengers' curpoint // SELECT `passenger`.`aid`, `passenger`.`curpoint` FROM `passenger` WHERE (NOT `passenger`.`finished`) AND `passenger`.`aid` = $passCurpoints = array(); if (count($data['pids'])) { $passCurpoints = array(); $passCurpointSql = 'SELECT `passenger`.`aid`, `passenger`.`curpoint` FROM `passenger` WHERE (NOT `passenger`.`finished`) AND `passenger`.`aid` IN (' . join(",", $data['pids']) . ')'; $passCurpoint = mysql_query($passCurpointSql); while ($lineData = mysql_fetch_array($passCurpoint, MYSQL_ASSOC)) { if (in_array($lineData['aid'], $data['pids']) && $lineData['aid'] != $calResult[0]['id']) {
} // to client str // {"driver":{"Name": "a", "CurPoint": 1, "Path": 1}} $clientStr = '{"driver":{"Name": "' . $driverDatas['Name'] . '", "CurPoint": ' . $driverDatas['curpoint'] . ', "Path": ' . json_encode($driverDatas['Path']) . '}}'; echo $clientStr; } } else { if ($data['resetStatus']) { // update passenger get in and get out off car state // UPDATE `passenger` SET `passenger`.`getinStatus` = 0, `passenger`.`getoffStatus` = 0 WHERE (NOT `passenger`.`finished`) AND `passenger`.`aid` = 1046779538684831 $UpdatePassStatusSql = 'UPDATE `passenger` SET `passenger`.`getinStatus` = 0, `passenger`.`getoffStatus` = 0 WHERE (NOT `passenger`.`finished`) AND `passenger`.`aid` = ' . $data['pid']; $UpdatePassStatusResult = mysql_query($UpdatePassStatusSql); } else { // Get necessary data from db // function GetneceData($pid, $dids, $onlyPath) $neceData = GetneceData($data['pid'], $data['dids'], $data['curdriveridx']); // first update driver current point UpdateCurrentPoint($data['pid'], $data['curpoint']); // determine target point owner if get in car or get out off car $calResult = DetResult($neceData); echo '{"calResult":' . $calResult . ', "driverCurpoints" : ' . json_encode($neceData['driversCurpoint']) . '}'; } } /* ************************************************************************************************** ************************************************************************************************** * FUNCTION DEFINITION START * ************************************************************************************************** ************************************************************************************************** */ // get necessary data