Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8918085
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T05:39:42+00:00 2026-06-15T05:39:42+00:00

Here is the SQL for one of my queries: private static function getFixedFare($post_code_a, $post_code_b)

  • 0

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;

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T05:39:44+00:00Added an answer on June 15, 2026 at 5:39 am

    Try this:

    $value = $result['Car'][0]['Fare'];
    

    The value for $result['Car'] is an array, with the index of the first element being 0; the value of that first element is an array again (one item, key ‘Fare’, value 100).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here's what I'm envisioning. Take a database (this one uses sql server 2008 spatial
I found something that works with updating one field at here: http://www.karlrixon.co.uk/articles/sql/update-multiple-rows-with-different-values-and-a-single-sql-query/ UPDATE person
I am new to SQL Server 2008 fill factor, as mentioned here in SQL
Oracle SQL can do hierarchical queries since v2, using their proprietary CONNECT BY syntax.
I have a really weird issue with Sql queries on unicode data. Here's what
I have 2 sql queries in my code where the second one is wrapped
I was playing around with SQL Queries and this one came to my mind
I have 3 queries that I need combined into one. Here they are SELECT
I'd like Symfony to log the Doctrine SQL queries that one of my tasks
SQL queries are still my weakest point, so here I am with yet another

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.