/** * Find a single truck based on their primary key! */ public function actionTruck($id) { $truck = Trucks::get_truck_by_id($id); if (count($truck)) { $this->sendJsonResponse(array('status' => 'success', 'data' => $truck[0])); } else { $this->sendJsonResponse(array('status' => 'fail', 'data' => 'This truck does not exist..')); } }