Welcome Guest, Not a member yet? Register   Sign In
DMZ (Datamapper) quick query question
#1

[eluser]kungpoo[/eluser]
I love the idea of what the Datamapper could do for my projects. I'm trying to get my head around a very basic many-to-many join using the tables students, courses_students and courses.

The code to list all courses for a student that I am using is as follows -

Code:
$s = new Student();
$s->get();

foreach ($s->course->get() as $c) {
    echo $c->name;
}

$this->output->enable_profiler(TRUE);

My first question was related to what the profiler shows is happening to the DB -
Code:
SELECT * FROM `students` LIMIT 1
Code:
SELECT * FROM (`students`)
Code:
SELECT * FROM `courses` LIMIT 1
Code:
SELECT `courses`.*
FROM (`courses`)
LEFT OUTER JOIN `courses_students` courses_students ON `courses`.`id` = `courses_students`.`course_id`
WHERE `courses_students`.`student_id` = 1
Are all of these SELECT statements meant to be there? Should I be doing something differently?

Sorry for my ignorance! I seem to just be the to many stuff that is giving me grief. Thanks.


Messages In This Thread
DMZ (Datamapper) quick query question - by El Forum - 07-07-2010, 06:47 AM
DMZ (Datamapper) quick query question - by El Forum - 07-07-2010, 07:01 AM
DMZ (Datamapper) quick query question - by El Forum - 07-07-2010, 07:04 AM



Theme © iAndrew 2016 - Forum software by © MyBB