Welcome Guest, Not a member yet? Register   Sign In
Database Active Record error... I think?
#1

[eluser]gregmax17[/eluser]
Hello, I have been CI for a while and it is a great tool. I have just started to learn how to use the Active Record class (before I did all the query by hand), and I have come to stump using it.

I am trying to do a query like so:

SELECT
`users`.`username`, `users`.`privilege_id`
FROM
`users`, `privileges`
WHERE
`users`.`privilege_id`=`privileges`.`privilege_id`

Using the "query" method this works great, but not with the Active Record. It assumes `privileges`.`privilege_id` is a value. So the query comes back as:

SELECT
`users`.`username`, `users`.`privilege_id`
FROM
`users`, `privileges`
WHERE
`users`.`privilege_id`='privileges.privilege_id'

Of course this doesn't return any results.

Any help would be great, thanks
#2

[eluser]Dam1an[/eluser]
It might help if you also included the actual code for the active record, just to be sure there's nothing wrong with that
#3

[eluser]gregmax17[/eluser]
Here is the code I have:

Code:
$users = $this->db->select('users.username, privileges.privilege')->order_by('users.username')->get_where('users, privileges', array('users.privilege_id' => 'privileges.privilege_id'));




Theme © iAndrew 2016 - Forum software by © MyBB