bvfbarten/f3-model

There is no license information available for the latest version (0.4) of this package.

Simple model class for f3 framework

Maintainers

👁 bvfbarten

Package info

github.com/bvfbarten/f3-model

pkg:composer/bvfbarten/f3-model

Statistics

Installs: 54

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

0.4 2023-01-28 00:09 UTC

Requires

Requires (Dev)

None

Suggests

None

Provides

None

Conflicts

None

Replaces

None

Unknown License a3f95b7123cde1f540ac6f4a109f270895844757

  • Brady Barten <bvfbarten.woop@gmail.com>

This package is not auto-updated.

Last update: 2026-06-27 15:08:55 UTC


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