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
- -studentid (PK) -firstname -surname -dateofbirth -vmg -yeargroup
link
- -linkid (PK) -studentid (FK) -pledgeid (FK) -timeofaward
pledges
- -pledgeid (PK) -pledgename -pledgeinfo
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>";
}
?>
- Is my data structure correct for using NotORM
- How do I translate the example so that it shows the students and which awards have been awarded to them. - I feel like I have tried every variation of that code and still can't get it to work.
Many thanks in advance.