2 Foreign keys to the same table

Notice: This thread is very old.
regex
Member | 1
+
0
-

I have 2 tables
‘posts’ with ‘id,id_createdBy, id_publishedBy,…’
‘user’ with ‘id,…’
id_createdBy and id_publishedBy are foreign keys to user.id

in the templates i can use:
$post->ref(‘user’, ‘id_createdBy’)->name

but how can i make this in sql? Something like:
$this->db->table(‘post’)->ref(‘user’,‘id_createdBy’)->select(‘post.*, user.name as createdByUser’)->where(‘......’)