/** * Convert result rows into object instances. * * \param $class Class name * * \param $rows * The rows with data (or an empty array). * * \return * An array with references to new instances or an empty array no data was provided * * \see db_objects_from_arrays * \see _db_objects_from_array */ protected static final function _db_objects_from_arrays($class, $rows) { assert('is_numeric_array($rows)'); $out = array(); foreach ($rows as $row) { $out[] = AnewtAutoRecord::_db_object_from_array($class, $row); } return $out; }
{ return 'age'; } /** * Simple database layout */ static function db_columns() { return array('id' => 'integer', 'name' => 'string', 'age' => 'integer', 'is_happy' => 'boolean'); } static function db_columns_order_by() { return array('age' => 'ASC', 'name' => 'DESC'); } } AnewtAutoRecord::register('Person'); class AnewtAutoRecordTest extends PHPUnit_Framework_TestCase { public function setup() { } public function teardown() { } /** * Test the AutoRecord retrieval methods. */ function test_find() { $result = Person::db_find_one_by_id(2); $this->assertNotNull($result);