<?php /** * Copyright (c) 2012 Ryan Yonzon, <*****@*****.**> * Dual licensed under the MIT and GPL licenses: * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl.html */ // Enable full-blown error reporting. http://twitter.com/rasmus/status/7448448829 error_reporting(-1); require '../ormbit.init.php'; // require and initialize ORMbit class // intantiate: /models/employee.model.php $employee = new employee(); // find twenty(20) employee records $employee->find(array('limit' => '0,20')); // get the first record $employee->first(); // print out echo $employee->id . ", " . $employee->first_name . ", " . $employee->last_name . ", " . $employee->name . "\n"; // -EOF-
function index() { /* * do nothing, let the view engine render associated contents */ /* * test model */ $employee = new employee(); $employee->find(array('limit' => '0,100')); echo '<br />Record count (All): ' . $employee->record_count(); echo '<br /><table border="1" style="border-collapse:collapse;">'; while ($employee->next()) { echo '<tr>'; echo '<td>' . $employee->id . '</td>'; echo '<td>' . $employee->first_name . '</td>'; echo '<td>' . $employee->last_name . '</td>'; echo '<td>' . $employee->name . '</td>'; echo '</tr>'; } echo '</table>'; //$employee->iterate(); /* * get first record */ $resp = $employee->first(); // go to first record echo '<h1>First Record</h1>'; echo '<br /><table border="1" style="border-collapse:collapse;">'; echo '<tr>'; echo '<td>' . $employee->id . '</td>'; echo '<td>' . $employee->first_name . '</td>'; echo '<td>' . $employee->last_name . '</td>'; echo '<td>' . $employee->name . '</td>'; echo '</tr>'; /*while ($employee->iterate()) { echo '<tr>'; echo '<td>' . $employee->id . '</td>'; echo '<td>' . $employee->first_name . '</td>'; echo '<td>' . $employee->last_name . '</td>'; echo '<td>' . $employee->name . '</td>'; echo '</tr>'; }*/ echo '</table>'; /* * get last record */ $resp = $employee->last(5); // go to last record echo '<h1>Last Record</h1>'; echo '<br /><br /><table border="1" style="border-collapse:collapse;">'; while ($employee->next()) { echo '<tr>'; echo '<td>' . $employee->id . '</td>'; echo '<td>' . $employee->first_name . '</td>'; echo '<td>' . $employee->last_name . '</td>'; echo '<td>' . $employee->name . '</td>'; echo '</tr>'; } echo '</table>'; /* * end test model */ }