I have a class called TariffFareController, and I am getting the correct fare from the database as follows:-
class TariffFareController {
public static function getTourFare($fieldTour) {
$pdo = new SQL();
$dbh = $pdo->connect(Database::$serverIP, Database::$serverPort, Database::$dbName, Database::$user, Database::$pass);
try {
$query = "SELECT Fare FROM tbltours
WHERE TourName = '$fieldTour'";
$stmt = $dbh->prepare($query);
$stmt->execute();
$result = $stmt->fetchColumn();
$stmt->closeCursor();
return $result;
$dbh = null;
}
catch (PDOException $pe) {
die("Error: " .$pe->getMessage(). " Query: ".$stmt->queryString);
}
}
}
I then want to be able to check the result in my private get fare function:-
private static function getFare($int_terminate) {
// $tour_fare = (the result from getTourFare)
if ($tour_fare != null) {
// do something
}
else {
// do something else
}
}
How would I go about getting the $result from getTourFare and using this in the private getFare function?
Any help would be much appreciated!
return $result;don't get executed. You need to move$dbh = null;up or it won't be done.