yeah raju vai
I also tried like below
$this->db->select('tbl_customer.*,tbl_sales.*');
but i did not get desired result.
Hi,
Did you selected ($this->db->select()) the columns from the second table?
Best Regard,
Raju
------------------------
http://hungrycoder.xenexbd.com - For novice.
On Sat, Jul 23, 2011 at 10:14 PM, asma tuli <asmatuli@gmail.com> wrote:
My problem is in this line
$this->db->join('tbl_sales', 'tbl_sales.customer_id = tbl_customer.customer_id');
If I write the code like above line it shows nothing in view even no error is coming.
On the other hand if I write code like the below line I got only the values of first table not the second table .
$this->db->join('tbl_sales', 'tbl_sales.customer_id = tbl_customer.customer_id', 'left');
What I have to do if same column name is in two table??
I am not so expert in join with codeigniter. That's why I am little bit confused, how to show data in view. So if you have any good tutorial regarding mysql join with codeigniter , you can share it with me.
On Sat, Jul 23, 2011 at 9:43 PM, Md.Shoriful Islam Ronju <smronju@gmail.com> wrote:Try this...
$sql = $this->db->select('*')
->from('tbl_customer')->get();
->join('tbl_sales','tbl_sales.customer_id = tbl_customer.customer_id')
return $sql->result();--On Sat, Jul 23, 2011 at 2:25 PM, asma tuli <asmatuli@gmail.com> wrote:
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.
:: Md.Shoriful Islam Ronju ::
http://blog.smronju.com
No comments:
Post a Comment