public static function getRandObjects($pk, $whereSection = null, $cantidad = 1) { return _::factory(self::getRand($pk, $whereSection, $cantidad), $pk, self::tablename()); }
_::redirect('example_3'); // from here it doesn't execute. // if you like redirect client web browser, use: _::redirect('http://google.com', false); // this stop execution of current code. // if you need make all records of a table, you can use: $records = model::getAll(); // this is SELECT * FROM TABLE; // if you like add limit, you can use second parammeter: $records = model::getAll('LIMIT 1'); // in the second parammeter you can use WHERE clausule, ORDER BY and LIMIT. // getAll is a magic function of ORM, you don't need define it in the model. // now, $records get an Array of ids, you need make one object at each. // you can use foreach: /** $objects = array(); foreach($records as $one_record) { $objects[] = new model($one_record['primary_key']); } */ // OR YOU CAN USE FRAMEWORK TO MAKE EASY: $objects = _::factory($records, 'primary_key', 'model'); // of course, you replace primary_key and model. // now you have one object each record. // and you can set new values, use the current values, delete the record, etc. // you can make new functions for check if exists record, and custom functions of getAll in the model using parent::getAll('query'); // remember, the objets represents records, the class represent the table. // the static functions affect all records. // the functions of the object affect one record. });