Welcome Guest, Not a member yet? Register   Sign In
Compare two variables of differents tables with active record..

Hello everyone, In this moment I want to do a comparation of two differents tables for may use it like result.

$this -> db -> select('*');
$this -> db -> from('functions, users');
$this -> db -> where('idprofile=' . 'createdby');
$query = $this -> db -> get();
return $query;

I'm doing a table that to show two varables of the functions table but I have a row in the database which is "createdby" and its a number, But I want that show the name of the person, For this I have a foreign key, from the createdby row from functions to idprofile from users. So I want that Instead of to show the number of createdby. Show the name of the person about to the corresponding.

Someone that may help me please. Ideas!!!


Look at the "join()" method.

Thanks by your response.

Will be like this:
$this -> db -> select('*');
$this -> db -> from('funciones, usuario');
$this -> db -> join('usuario', 'usuario.idusuario = funciones.creadopor');
$query = $this -> db -> get();
return $query;

But of this way donĀ“t works.

"This way don't works" doesn't help. What is the result you're getting? What result are you expecting? Details please, or NOBODY will be able to help very well.

Again thanks by your responses.

see. I need to show a table with 3 rows of the table functions and one row more but of the table ID in the same function.

So I have this. ||name ||lastname ||father || mother|| -> Captions.
I going to show this: ||Diego ||Dominguez ||somenone || 1 || -> these info is from my table x.

Now I want to show this: ||Diego ||Dominguez ||someone || linda || -> The linda data is from my table users.

My table x is like this: ||id||Diego ||Dominguez ||somenone || 1 ||
My table users is like this: ||id||worker ||tall ||george || linda ||

I need that Instead of to show 1 show the name of the mother, The rows are links with a foreign key..

Obvisuly that is a example but this is basically I want to do..

Theme © iAndrew 2016 - Forum software by © MyBB