generated DB models

This commit is contained in:
2026-02-12 01:18:15 +01:00
parent 62552fe596
commit 6b718a3cfa
7 changed files with 575 additions and 0 deletions

View File

@ -0,0 +1,81 @@
<?php
/*
TPsoft.org 2000-2026
file for controlers/*.php
Milestones:
2026-02-12 01:16 Created
*/
namespace TPsoft\Nutrio\Models;
class DiaryDays extends \TPsoft\DBmodel\DBmodel {
public $tables = array(
'diaryDays' => array(
'name' => 'diary_days',
'primary_key_name' => 'diary_day_id',
'allow_attributes' => array(
'user_id' => 'bigint(20) unsigned',
'day_date' => 'date',
'created_at' => 'datetime'
)
),
);
public function exist($primary_key = null) {
return $this->existRecord('diaryDays', $primary_key);
}
public function diaryDay($primary_key = null, $data = array()) {
return $this->record('diaryDays', $primary_key, $data);
}
public function diaryDayBy($colname, $colvalue) {
return $this->recordBy('diaryDays', $colname, $colvalue);
}
public function diaryDaySave($data = array()) {
return $this->diaryDay($this->exist($data) ? $data : null, $data);
}
public function diaryDayEmpty() {
return $this->recordEmpty('diaryDays');
}
public function diaryDayAttributes() {
return $this->typesAttributes('diaryDays');
}
public function diaryDayCount() {
return $this->count('diaryDays');
}
public function getList($search = array(), $reverse = false, $concat_or = false) {
return $this->search('diaryDays')
->where($search, $concat_or)
->order(array('diary_day_id' => $reverse ? 'DESC' : 'ASC'))
->toArray();
}
public function getListOrganize($cola_name, $search = array(), $reverse = false, $concat_or = false) {
$all = $this->getList($search, $reverse, $concat_or);
$ret = array();
if (is_array($all)) foreach ($all as $key => $row) {
$ret[$row[$cola_name]] = $row;
}
return $ret;
}
public function getListByID($search = array(), $reverse = false, $concat_or = false) {
return $this->getListOrganize('diary_day_id', $search, $reverse, $concat_or);
}
public function diaryDayCombo($col_key, $col_value, $add_empty = false) {
return $this->search('diaryDays')
->toCombo($col_key, $col_value, $add_empty);
}
}
?>

View File

@ -0,0 +1,82 @@
<?php
/*
TPsoft.org 2000-2026
file for controlers/*.php
Milestones:
2026-02-12 01:16 Created
*/
namespace TPsoft\Nutrio\Models;
class DiaryEntries extends \TPsoft\DBmodel\DBmodel {
public $tables = array(
'diaryEntries' => array(
'name' => 'diary_entries',
'primary_key_name' => 'diary_entry_id',
'allow_attributes' => array(
'diary_day_id' => 'bigint(20) unsigned',
'meal_type' => 'enum("breakfast","lunch","dinner")',
'meal_id' => 'bigint(20) unsigned',
'created_at' => 'datetime'
)
),
);
public function exist($primary_key = null) {
return $this->existRecord('diaryEntries', $primary_key);
}
public function diaryEntry($primary_key = null, $data = array()) {
return $this->record('diaryEntries', $primary_key, $data);
}
public function diaryEntryBy($colname, $colvalue) {
return $this->recordBy('diaryEntries', $colname, $colvalue);
}
public function diaryEntrySave($data = array()) {
return $this->diaryEntry($this->exist($data) ? $data : null, $data);
}
public function diaryEntryEmpty() {
return $this->recordEmpty('diaryEntries');
}
public function diaryEntryAttributes() {
return $this->typesAttributes('diaryEntries');
}
public function diaryEntryCount() {
return $this->count('diaryEntries');
}
public function getList($search = array(), $reverse = false, $concat_or = false) {
return $this->search('diaryEntries')
->where($search, $concat_or)
->order(array('diary_entry_id' => $reverse ? 'DESC' : 'ASC'))
->toArray();
}
public function getListOrganize($cola_name, $search = array(), $reverse = false, $concat_or = false) {
$all = $this->getList($search, $reverse, $concat_or);
$ret = array();
if (is_array($all)) foreach ($all as $key => $row) {
$ret[$row[$cola_name]] = $row;
}
return $ret;
}
public function getListByID($search = array(), $reverse = false, $concat_or = false) {
return $this->getListOrganize('diary_entry_id', $search, $reverse, $concat_or);
}
public function diaryEntryCombo($col_key, $col_value, $add_empty = false) {
return $this->search('diaryEntries')
->toCombo($col_key, $col_value, $add_empty);
}
}
?>

View File

@ -0,0 +1,87 @@
<?php
/*
TPsoft.org 2000-2026
file for controlers/*.php
Milestones:
2026-02-12 01:13 Created
*/
namespace TPsoft\Nutrio\Models;
class Ingredients extends \TPsoft\DBmodel\DBmodel {
public $tables = array(
'ingredients' => array(
'name' => 'ingredients',
'primary_key_name' => 'ingredient_id',
'allow_attributes' => array(
'user_id' => 'bigint(20) unsigned',
'name' => 'varchar(255)',
'protein_g_100' => 'decimal(7,2)',
'carbs_g_100' => 'decimal(7,2)',
'sugar_g_100' => 'decimal(7,2)',
'fat_g_100' => 'decimal(7,2)',
'fiber_g_100' => 'decimal(7,2)',
'kcal_100' => 'decimal(8,2)',
'created_at' => 'datetime'
)
),
);
public function exist($primary_key = null) {
return $this->existRecord('ingredients', $primary_key);
}
public function ingredient($primary_key = null, $data = array()) {
return $this->record('ingredients', $primary_key, $data);
}
public function ingredientBy($colname, $colvalue) {
return $this->recordBy('ingredients', $colname, $colvalue);
}
public function ingredientSave($data = array()) {
return $this->ingredient($this->exist($data) ? $data : null, $data);
}
public function ingredientEmpty() {
return $this->recordEmpty('ingredients');
}
public function ingredientAttributes() {
return $this->typesAttributes('ingredients');
}
public function ingredientCount() {
return $this->count('ingredients');
}
public function getList($search = array(), $reverse = false, $concat_or = false) {
return $this->search('ingredients')
->where($search, $concat_or)
->order(array('ingredient_id' => $reverse ? 'DESC' : 'ASC'))
->toArray();
}
public function getListOrganize($cola_name, $search = array(), $reverse = false, $concat_or = false) {
$all = $this->getList($search, $reverse, $concat_or);
$ret = array();
if (is_array($all)) foreach ($all as $key => $row) {
$ret[$row[$cola_name]] = $row;
}
return $ret;
}
public function getListByID($search = array(), $reverse = false, $concat_or = false) {
return $this->getListOrganize('ingredient_id', $search, $reverse, $concat_or);
}
public function ingredientCombo($col_key, $col_value, $add_empty = false) {
return $this->search('ingredients')
->toCombo($col_key, $col_value, $add_empty);
}
}
?>

View File

@ -0,0 +1,82 @@
<?php
/*
TPsoft.org 2000-2026
file for controlers/*.php
Milestones:
2026-02-12 01:15 Created
*/
namespace TPsoft\Nutrio\Models;
class MealItems extends \TPsoft\DBmodel\DBmodel {
public $tables = array(
'mealItems' => array(
'name' => 'meal_items',
'primary_key_name' => 'meal_item_id',
'allow_attributes' => array(
'meal_id' => 'bigint(20) unsigned',
'ingredient_id' => 'bigint(20) unsigned',
'grams' => 'decimal(10,2)',
'position' => 'int(10) unsigned'
)
),
);
public function exist($primary_key = null) {
return $this->existRecord('mealItems', $primary_key);
}
public function mealItem($primary_key = null, $data = array()) {
return $this->record('mealItems', $primary_key, $data);
}
public function mealItemBy($colname, $colvalue) {
return $this->recordBy('mealItems', $colname, $colvalue);
}
public function mealItemSave($data = array()) {
return $this->mealItem($this->exist($data) ? $data : null, $data);
}
public function mealItemEmpty() {
return $this->recordEmpty('mealItems');
}
public function mealItemAttributes() {
return $this->typesAttributes('mealItems');
}
public function mealItemCount() {
return $this->count('mealItems');
}
public function getList($search = array(), $reverse = false, $concat_or = false) {
return $this->search('mealItems')
->where($search, $concat_or)
->order(array('meal_item_id' => $reverse ? 'DESC' : 'ASC'))
->toArray();
}
public function getListOrganize($cola_name, $search = array(), $reverse = false, $concat_or = false) {
$all = $this->getList($search, $reverse, $concat_or);
$ret = array();
if (is_array($all)) foreach ($all as $key => $row) {
$ret[$row[$cola_name]] = $row;
}
return $ret;
}
public function getListByID($search = array(), $reverse = false, $concat_or = false) {
return $this->getListOrganize('meal_item_id', $search, $reverse, $concat_or);
}
public function mealItemCombo($col_key, $col_value, $add_empty = false) {
return $this->search('mealItems')
->toCombo($col_key, $col_value, $add_empty);
}
}
?>

View File

@ -0,0 +1,82 @@
<?php
/*
TPsoft.org 2000-2026
file for controlers/*.php
Milestones:
2026-02-12 01:14 Created
*/
namespace TPsoft\Nutrio\Models;
class Meals extends \TPsoft\DBmodel\DBmodel {
public $tables = array(
'meals' => array(
'name' => 'meals',
'primary_key_name' => 'meal_id',
'allow_attributes' => array(
'user_id' => 'bigint(20) unsigned',
'name' => 'varchar(255)',
'meal_type' => 'enum("breakfast","lunch","dinner")',
'created_at' => 'datetime'
)
),
);
public function exist($primary_key = null) {
return $this->existRecord('meals', $primary_key);
}
public function meal($primary_key = null, $data = array()) {
return $this->record('meals', $primary_key, $data);
}
public function mealBy($colname, $colvalue) {
return $this->recordBy('meals', $colname, $colvalue);
}
public function mealSave($data = array()) {
return $this->meal($this->exist($data) ? $data : null, $data);
}
public function mealEmpty() {
return $this->recordEmpty('meals');
}
public function mealAttributes() {
return $this->typesAttributes('meals');
}
public function mealCount() {
return $this->count('meals');
}
public function getList($search = array(), $reverse = false, $concat_or = false) {
return $this->search('meals')
->where($search, $concat_or)
->order(array('meal_id' => $reverse ? 'DESC' : 'ASC'))
->toArray();
}
public function getListOrganize($cola_name, $search = array(), $reverse = false, $concat_or = false) {
$all = $this->getList($search, $reverse, $concat_or);
$ret = array();
if (is_array($all)) foreach ($all as $key => $row) {
$ret[$row[$cola_name]] = $row;
}
return $ret;
}
public function getListByID($search = array(), $reverse = false, $concat_or = false) {
return $this->getListOrganize('meal_id', $search, $reverse, $concat_or);
}
public function mealCombo($col_key, $col_value, $add_empty = false) {
return $this->search('meals')
->toCombo($col_key, $col_value, $add_empty);
}
}
?>

View File

@ -0,0 +1,80 @@
<?php
/*
TPsoft.org 2000-2026
file for controlers/*.php
Milestones:
2026-02-12 01:17 Created
*/
namespace TPsoft\Nutrio\Models;
class Options extends \TPsoft\DBmodel\DBmodel {
public $tables = array(
'options' => array(
'name' => 'options',
'primary_key_name' => 'key',
'allow_attributes' => array(
'key' => 'varchar(255)',
'value' => 'varchar(255)'
)
),
);
public function exist($primary_key = null) {
return $this->existRecord('options', $primary_key);
}
public function option($primary_key = null, $data = array()) {
return $this->record('options', $primary_key, $data);
}
public function optionBy($colname, $colvalue) {
return $this->recordBy('options', $colname, $colvalue);
}
public function optionSave($data = array()) {
return $this->option($this->exist($data) ? $data : null, $data);
}
public function optionEmpty() {
return $this->recordEmpty('options');
}
public function optionAttributes() {
return $this->typesAttributes('options');
}
public function optionCount() {
return $this->count('options');
}
public function getList($search = array(), $reverse = false, $concat_or = false) {
return $this->search('options')
->where($search, $concat_or)
->order(array('key' => $reverse ? 'DESC' : 'ASC'))
->toArray();
}
public function getListOrganize($cola_name, $search = array(), $reverse = false, $concat_or = false) {
$all = $this->getList($search, $reverse, $concat_or);
$ret = array();
if (is_array($all)) foreach ($all as $key => $row) {
$ret[$row[$cola_name]] = $row;
}
return $ret;
}
public function getListByID($search = array(), $reverse = false, $concat_or = false) {
return $this->getListOrganize('key', $search, $reverse, $concat_or);
}
public function optionCombo($col_key, $col_value, $add_empty = false) {
return $this->search('options')
->toCombo($col_key, $col_value, $add_empty);
}
}
?>

View File

@ -0,0 +1,81 @@
<?php
/*
TPsoft.org 2000-2026
file for controlers/*.php
Milestones:
2026-02-12 01:12 Created
*/
namespace TPsoft\Nutrio\Models;
class Users extends \TPsoft\DBmodel\DBmodel {
public $tables = array(
'users' => array(
'name' => 'users',
'primary_key_name' => 'user_id',
'allow_attributes' => array(
'email' => 'varchar(255)',
'password_hash' => 'varchar(255)',
'created_at' => 'datetime'
)
),
);
public function exist($primary_key = null) {
return $this->existRecord('users', $primary_key);
}
public function user($primary_key = null, $data = array()) {
return $this->record('users', $primary_key, $data);
}
public function userBy($colname, $colvalue) {
return $this->recordBy('users', $colname, $colvalue);
}
public function userSave($data = array()) {
return $this->user($this->exist($data) ? $data : null, $data);
}
public function userEmpty() {
return $this->recordEmpty('users');
}
public function userAttributes() {
return $this->typesAttributes('users');
}
public function userCount() {
return $this->count('users');
}
public function getList($search = array(), $reverse = false, $concat_or = false) {
return $this->search('users')
->where($search, $concat_or)
->order(array('user_id' => $reverse ? 'DESC' : 'ASC'))
->toArray();
}
public function getListOrganize($cola_name, $search = array(), $reverse = false, $concat_or = false) {
$all = $this->getList($search, $reverse, $concat_or);
$ret = array();
if (is_array($all)) foreach ($all as $key => $row) {
$ret[$row[$cola_name]] = $row;
}
return $ret;
}
public function getListByID($search = array(), $reverse = false, $concat_or = false) {
return $this->getListOrganize('user_id', $search, $reverse, $concat_or);
}
public function userCombo($col_key, $col_value, $add_empty = false) {
return $this->search('users')
->toCombo($col_key, $col_value, $add_empty);
}
}
?>