You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
67 lines
2.2 KiB
67 lines
2.2 KiB
<?php
|
|
|
|
namespace model;
|
|
|
|
use DAL\Connection;
|
|
use DAL\FluxGateway;
|
|
use metier\Flux;
|
|
|
|
class FluxModel
|
|
{
|
|
public function FindAllFlux(){
|
|
$gateway = new FluxGateway(new Connection('mysql:host=londres.uca.local;dbname=dbrorossetto','rorossetto','tpphp'));
|
|
$data = array();
|
|
$result = $gateway->findAllFlux();
|
|
|
|
foreach ($result as $row){
|
|
$data[] = new Flux((int)$row['id'],$row['$flux']);
|
|
}
|
|
return $data;
|
|
}
|
|
|
|
public function addFlux(Flux $flux){
|
|
$gateway = new FluxGateway(new Connection('mysql:host=londres.uca.local;dbname=dbrorossetto','rorossetto','tpphp'));
|
|
$data = $this->findFlux($flux);
|
|
if ($data == array()) {
|
|
$gateway->addFlux($flux);
|
|
}
|
|
}
|
|
|
|
public function addFluxBySrc(string $flux): Flux {
|
|
$gateway = new FluxGateway(new Connection('mysql:host=londres.uca.local;dbname=dbrorossetto','rorossetto','tpphp'));
|
|
$newFlux = new Flux($flux);
|
|
$gateway->addFlux($newFlux);
|
|
return $newFlux;
|
|
}
|
|
|
|
public function removeFlux(Flux $flux){
|
|
$gateway = new FluxGateway(new Connection('mysql:host=londres.uca.local;dbname=dbrorossetto','rorossetto','tpphp'));
|
|
$gateway->removeFlux($flux);
|
|
}
|
|
|
|
public function removeFluxBySrc(string $flux) {
|
|
$gateway = new FluxGateway(new Connection('mysql:host=londres.uca.local;dbname=dbrorossetto','rorossetto','tpphp'));
|
|
$gateway->removeFlux($flux);
|
|
}
|
|
|
|
public function findFlux(Flux $flux){
|
|
$gateway = new FluxGateway(new Connection('mysql:host=londres.uca.local;dbname=dbrorossetto','rorossetto','tpphp'));
|
|
$data = array();
|
|
$result = $gateway->findFlux($flux);
|
|
|
|
foreach ($result as $row){
|
|
$data[] = new Flux($row['$flux'],(int)$row['id']);
|
|
}
|
|
return $data;
|
|
}
|
|
|
|
public function findFluxBySrc(string $flux){
|
|
$gateway = new FluxGateway(new Connection('mysql:host=londres.uca.local;dbname=dbrorossetto','rorossetto','tpphp'));
|
|
$result = $gateway->findFluxBySrc($flux);
|
|
|
|
foreach ($result as $row){
|
|
$data[] = new Flux($row['$flux'],(int)$row['id']);
|
|
}
|
|
return $data;
|
|
}
|
|
} |