Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End Codeigniter SQL

  • This topic is empty.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #36644
    ben_hawk
    Participant

    Hi,

    I am trying to run an SQL query in codeigniter which looks as follows


    function getActiveBookings() {

    $this->buildMaps();

    $query = $this->db->get_where('Bookings', array('Status' => 0, 'Driver_ID' => null));

    if($query->num_rows() > 0) {
    $data = array();

    foreach($query->result() as $row){
    $row->customer = $this->get_customer($row->Customer_ID);
    $data[] = $row; }
    return $data;
    }
    else{
    return false;
    }
    }

    This grabs all bookings and if a customer ID is assigned grab the customer information too.

    However I am having trouble getting the customer information out in the view, I am trying to following


    customer->Name; ?>

    How this gives me the error

    A PHP Error was encountered
    Severity: Notice
    Message: Trying to get property of non-object
    Filename: admin/dashboard.php
    Line Number: 30

    Can anyone help?

    Cheers

    #96762
    ShawnC
    Member

    Without all the code it’s hard to pinpoint the exact problem,

    but from what I’m seeing, you are returning a Array and Echoing a Object unless I’m not seeing something,

    Can you do a var_dump inside of your View file, you may also want to var_dump your controller before you load your view file.

    Another helpful feature I find when dealing with MVC patterns and variables is to dump the defined variables with

    php’s function get_defined_vars();



    var_dump ( $row );
    var_dump ( get_defined_vars() );

    Shawn Crigger
    S-Vizion Web Development’s
    Twitter : @svizion
    http://blog.s-vizion.com

Viewing 2 posts - 1 through 2 (of 2 total)
  • The forum ‘Back End’ is closed to new topics and replies.