bvfbarten / f3-model
There is no license information available for the latest version (0.4) of this package.
Simple model class for f3 framework
0.4
2023-01-28 00:09 UTC
Requires
- bcosca/fatfree: ^3.7
README
F3 Model strives to create lazy loading relations the fatfree way. It comes with four functions to add to the mapper object.
class UserGroup extends F3Model {
public $_db = 'db';
public $_table = 'user_group';
public function relations() {
return [
'User' => [
"User",
['id = ?', $this->user_id]
],
'Group' => [
"Group",
['id = ?', $this->group_id]
],
'NotFamily' => [
"Group",
['id != ? and name = ?', 3, 'family']
],
];
}
}
$userGroup = new UserGroup;
$user = $userGroup->loadRelation('User');
function findRelation($key, $where, $args) { }
returns array of NotFamily relationship
$where, gives ability to add additional where parameters to related table in same fashion as f3
$args, allows overriding $args given in initial relations function
function loadRelation($key, $where, $args) { }
returns a single object of NotFamily
function countRelation($key, $where, $args) { }
returns a count of NotFamily
function combineFilter($filter, $filter1) { } returns an f3 filter combining $filter and $filter1