SMMP/build/database/repo/module.php

90 lines
1.9 KiB
PHP

<?php
namespace database\repo;
use \database\core\DatabaseDriver;
use \error\core\Err;
use \database\core\Repo;
use \orm\core\Table;
use \orm\core\Rows;
class module extends parentRepo{
protected static function table_name(){ static $table_name = 'module'; return $table_name; }
/* [1] Fetch all modules
*
* @return modules<Array> The list of modules
* FALSE on error
*
=========================================================*/
public static function getAll(){
return Table::get('module')->select('*')->fetch();
}
/* [2] Fetch all modules for the given warehouse
*
* @id_warehouse<int> UID of the given warehouse
*
* @return modules<Array> The list of modules
* FALSE on error
*
=========================================================*/
public static function getForWarehouse($id_warehouse){
/* (1) Build request */
$modules = Table::get('module')->select('*');
$merge = Table::get('module_availability')->whereIdWarehouse($id_warehouse);
$merge->join('id_module', $modules);
return $merge->fetch();
}
/* [3] Fetch all modules for the given machine_cluster
*
* @id_warehouse<int> UID of the given warehouse
* @id_machine_cluster<int> UID of the given machine_cluster
*
* @return modules<Array> The list of modules
* FALSE on error
*
=========================================================*/
public static function getForMachineCluster($id_warehouse, $id_machine_cluster){
/* (1) On récupère le ETREE de la machine
---------------------------------------------------------*/
$module = Table::get('module')
->select('id_module')
->select('name');
$etree = Table::get('etree')
->join('id_module', $module);
$merge = Table::get('module_merge')
->join('id_etree', $etree)
->whereIdWarehouse($id_warehouse)
->whereIdMachineCluster($id_machine_cluster);
return $merge->fetch();
}
}
?>