Here is the SQL for one of my queries:
private static function getFixedFare($post_code_a, $post_code_b) {
$pdo = new SQL();
$dbh = $pdo->connect(Database::$serverIP, Database::$serverPort, Database::$dbName, Database::$user, Database::$pass);
try {
$query = "SELECT VehicleSystemId, Fare FROM tblfixedfares
WHERE ShortPostCodeA = '$post_code_a'
AND ShortPostCodeB = '$post_code_b'
AND DayHalf = :day_half
AND VehicleSystemId IN ('Car', '6B')";
$stmt = $dbh->prepare($query);
$stmt->bindParam(':day_half', self::$day_half, PDO::PARAM_STR);
$stmt->execute();
$result = $stmt->fetchAll(PDO::FETCH_ASSOC|PDO::FETCH_GROUP);
$stmt->closeCursor();
$dbh = null;
var_dump($result['Car']);
}
catch (PDOException $pe) {
die("Error: " .$pe->getMessage(). " Query: ".$stmt->queryString);
}
}
When I do a var_dump($result['Car']); I get the following response:
array(1) {
[0]=>
array(1) {
["Fare"]=>
string(3) "100"
}
}
How would I go about getting the value '100'... So basically the $result for ['Car'] ['Fare'] ?
Edit ::
var_dump($cars); shows:
array(2) {
["Car"]=>
array(1) {
[0]=>
array(1) {
["Fare"]=>
string(3) "100"
}
}
["6B"]=>
array(1) {
[0]=>
array(1) {
["Fare"]=>
string(3) "700"
}
}
I've tried; $result['Car']['Fare'] - but this is returning NULL;