Xataface 2.0
Xataface Application Framework
docs/examples/getRelatedRecords.example.php
Go to the documentation of this file.
00001 <?
00002 require_once 'dataface-public-api.php';
00003 
00004 // load student record with last name 'Hannah'
00005 $student =& df_get_record('Students', array('LastName'=>'Hannah'));
00006 
00007 // The $student variable now contains a Dataface_Record object.
00008 
00009 // Get the first 30 courses that this student has enrolled in -- assumes that the 'Courses' relationship is defined appropriately in relationships.ini file.
00010 $courses =& $student->getRelatedRecords('Courses')
00011 
00012 // $courses now contains an array of associative arrays with Course information.
00013 
00014 // Iterate through the courses and print them in a table.
00015 echo '<table>
00016         <thead>
00017          <tr>
00018           <th>Course ID</th>
00019           <th>Course Name</th>
00020           <th>Course Description</th>
00021          </tr>
00022         </thead>
00023         <tbody>
00024         ';
00025 foreach ( array_keys($courses) as $index){
00026         echo '
00027          <tr>
00028           <td>'.$courses[$index]['CourseID'].'</td>
00029           <td>'.$courses[$index]['CourseName'].'</td>
00030           <td>'.$courses[$index]['CourseDescription'].'</td>
00031          </tr>
00032         ';
00033 }
00034 echo '</tbody>
00035         </table>
00036         ';
00037 ?>
 All Data Structures Namespaces Files Functions Variables Enumerations