I'm learning NotORM to produce a simple system for school. I want to be able to award 'Pledges' to 'students'. Here is my data structure:
My tables:
students
link
pledges
The code from a great NotORM tutorial (http://www.sitepoint.com/database-interaction-made-easy-with-notorm/) says that I should do this:
<?php
foreach ($books as $book) {
echo "<tr>";
echo "<td>" . $book["title"] . "</td>";
echo "<td>" . $book["author"] . "</td>";
// book_category table joins book and category
$categories = array();
foreach ($book->book_category() as $book_category) {
$categories[] = $book_category->category["category"];
}
echo "<td>" . join(", ", $categories) . "</td>";
echo "</tr>";
}
?>
Many thanks in advance.
The key to your problem: starting from the Relation-Table (here Link) and relaying on NotORM to join the other tables.
See how simple the code may be:
$db->link("pledge.name", $someName)->select("student.firstname, student.lastname");