Welcome Guest, Not a member yet? Register   Sign In
HELP joining tables...
#1

[eluser]chazy (aldever calvo)[/eluser]
hello i really need help in joining tables for my get function
i have 3 tables:


user
-----
user_id(pk)
user_type_id(fk)
user_det_id(fk)

user_type
---------
user_type_id(pk)

user_details
------------
user_det_id(pk)


i had it joined and successfully output the result... but the problem is... i cannot do pagination with it...
my past code is this

Code:
function GetAllDetails()
    {
            
        $q = "SELECT A.user_id, A.uname, A.user_type_id, D.user_det_id, D.lname, D.fname, D.mname, D.email, T.user_type_name FROM user as A LEFT JOIN user_details as D ON A.user_id = D.user_det_id LEFT JOIN user_type as T ON A.user_type_id = T.user_type_id";
        $query = $this->db->query($q);
        
        return $query->result();
    }

and so what i did is change it into:
Code:
function GetAllDetails()
    {
        $this->db->join('choy_user_details', 'choy_user.choy_user_id = choy_user_details.choy_user_det_id');
        $this->db->join('choy_user_type', 'choy_user.choy_user_type_id = choy_user_type.choy_user_type_id', 'left');
        $this->db->where('choy_user_id', $userId);
        $query = $this->db->get('choy_user');
        
    
        return $query->result();
    }

But i have errors:

A PHP Error was encountered

Severity: Notice

Message: Undefined variable: userId

Filename: models/user_model.php

Line Number: 45

A PHP Error was encountered

Severity: Warning

Message: preg_match() expects parameter 2 to be string, object given

Filename: database/DB_driver.php

Line Number: 616


Please help me...


Messages In This Thread
HELP joining tables... - by El Forum - 01-11-2011, 11:02 AM
HELP joining tables... - by El Forum - 01-11-2011, 11:13 AM
HELP joining tables... - by El Forum - 01-11-2011, 11:46 AM
HELP joining tables... - by El Forum - 01-11-2011, 11:56 AM
HELP joining tables... - by El Forum - 01-11-2011, 12:05 PM
HELP joining tables... - by El Forum - 01-11-2011, 12:14 PM
HELP joining tables... - by El Forum - 01-11-2011, 12:24 PM
HELP joining tables... - by El Forum - 01-11-2011, 12:30 PM
HELP joining tables... - by El Forum - 01-11-2011, 12:55 PM
HELP joining tables... - by El Forum - 01-11-2011, 12:57 PM
HELP joining tables... - by El Forum - 01-11-2011, 01:02 PM
HELP joining tables... - by El Forum - 01-11-2011, 01:04 PM
HELP joining tables... - by El Forum - 02-11-2011, 12:34 AM



Theme © iAndrew 2016 - Forum software by © MyBB