本文整理汇总了PHP中DbHandler::getJourney方法的典型用法代码示例。如果您正苦于以下问题:PHP DbHandler::getJourney方法的具体用法?PHP DbHandler::getJourney怎么用?PHP DbHandler::getJourney使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DbHandler
的用法示例。
在下文中一共展示了DbHandler::getJourney方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: echoRespnse
array_push($response["journey"], $tmp);
}
echoRespnse(200, $response);
});
/**
* Listing single journey of particular user
* method GET
* url /journey/:id
* Will return 404 if the journey doesn't belongs to user
*/
$app->get('/journey/:id', 'authenticate', function ($journey_id) {
global $user_id;
$response = array();
$db = new DbHandler();
// fetch journey
$result = $db->getJourney($journey_id, $user_id);
if ($result != NULL) {
$response["error"] = false;
$response["id"] = $result["id"];
$response["journey_score"] = rand(1, 100);
//$result["journey_score"]; // generating random score since analysis doesnt work
$response["status"] = $result["status"];
$response["createdAt"] = $result["created_at"];
echoRespnse(200, $response);
} else {
$response["error"] = true;
$response["message"] = "The requested resource doesn't exists";
echoRespnse(404, $response);
}
});
/**
示例2: updateJourneyData
/**
* Updating Journey data table
* @param String $journey_id id of the journey
* @param String $user_id id of the user
* @param String $x_gps gps x coordinate
* @param String $y_gps gps y coordinate
* @param String $z_gps gps z coordinate
* @param String $x_acl accelerometer x coordinate
* @param String $y_acl accelerometer y coordinate
* @param String $z_acl accelerometer z coordinate
* @param String $timestamp time when data was sampled
* @param String $sample_no the sample number of the journey
*
* jd - journey data table
* j - journeys table
* uj - user journeys table
*/
public function updateJourneyData($journey_id, $user_id, $x_gps, $y_gps, $x_acl, $y_acl, $z_acl, $timestamp, $sample_no)
{
$db = new DbHandler();
$result = $db->getJourney($journey_id, $user_id);
if ($result == NULL) {
//journey doesnt belong to user or doesnt exist
return 0;
} else {
if ($result["status"] == 1) {
// cant add data information to a completed journey
return 0;
}
}
// At last we can add the journey data!
$stmt = $this->conn->prepare("INSERT INTO journey_data(journey_id, x_gps, y_gps, x_acl, y_acl, z_acl, time_stamp, sample_no) VALUES(?, ?, ?, ?, ?, ?, ?, ?)");
$stmt->bind_param("idddddsi", $journey_id, $x_gps, $y_gps, $x_acl, $y_acl, $z_acl, $timestamp, $sample_no);
$stmt->execute();
$num_affected_rows = $stmt->affected_rows;
$stmt->close();
return $num_affected_rows > 0;
}