Welcome Guest, Not a member yet? Register   Sign In
Seeking database class advice
#1

[eluser]Loquela[/eluser]
Hi there,

Wondering if anybody could suggest the most elegant way to translate the following SQL statement using CI Dtabase classs?

I know I can just use $this->db->select("SELECT...") but I am trying to get to grips with all the CI functions would like to try some alternatives. Cheers in advance!

Code:
SELECT topics.topic_id, topics.topic, topic2subject.topic_id, topic2subject.subject_id
FROM topics
Inner Join topic2subject
ON topic2subject.topic_id = topics.topic_id
WHERE topic2subject.subject_id = %s
ORDER BY topic

L.
#2

[eluser]Loquela[/eluser]
Got it. Thanks!

Code:
$this->db->select('topics.topic_id,topics.topic,topic2subject.topic_id,topic2subject.subject_id');
$this->db->from('pp_topics');
$this->db->where('topic2subject.subject_id', $subject_id);

$query = $this->db->get();




Theme © iAndrew 2016 - Forum software by © MyBB