Sunday, July 24, 2011

Re: [phpXperts] codeigniter and mysql inner join creating problem

 

Thanks all who replied and tried best to help me.

Actually there was a unkown database problem. I changed database and got amazing result.

take care

On Sun, Jul 24, 2011 at 4:36 PM, mahafuzur rahman <mahfuz_cse05@yahoo.com> wrote:
 

try this
$this->db->join('tbl_sales', 'tbl_sales.customer_id = tbl_customer.customer_id','left');

// for left join
   $query =  $this->db->select('*')
                                     ->from('tbl_customer')
                                     ->join('tbl_sales', 'tbl_sales.customer_id = tbl_customer.customer_id'
,'left')
                                   ->get();
if ($query->num_rows() > 0) {
 return $query->result();
        }
Best Regards
Mahfuz



From: asma tuli <asmatuli@gmail.com>
To: phpexperts <phpexperts@yahoogroups.com>
Sent: Saturday, July 23, 2011 2:25 PM
Subject: [phpXperts] codeigniter and mysql inner join creating problem

 
my model


function get_customer()
    {
       
        $this->db->select('*');
        $this->db->from('tbl_customer');
        $this->db->join('tbl_sales', 'tbl_sales.customer_id = tbl_customer.customer_id');
        $query = $this->db->get();
        return $query->result();
    }

my controller


function index()
    {
      $this->load->model('sh_model');
      $variable['customer'] = $this->sh_model->get_customer();
      $this->load->view('sh_view', $variable); 
    }


my view


foreach($customer as $item)
                {
                        echo $item->customer_id;
                        echo $item->customer_first_name;
                }



I am getting no result.





__._,_.___
Recent Activity:
Visit phpXperts website at www.phpxperts.net
MARKETPLACE

Stay on top of your group activity without leaving the page you're on - Get the Yahoo! Toolbar now.

.

__,_._,___

No comments:

Post a Comment