Files
api/src/Mapper/TipoTipologia.php
2022-06-13 21:36:52 -04:00

38 lines
1.1 KiB
PHP

<?php
namespace Incoviba\Mapper;
use Incoviba\Model\Model;
use Incoviba\Model\Proyecto\TipoTipologia as BaseModel;
class TipoTipologia extends Mapper
{
protected string $table = 'tipo_tipologia';
protected function load(bool|array $row, bool $lazy = false): BaseModel|bool
{
$model = new BaseModel();
$model->id = $row['id'];
$model->tipologia = $this->getMapper(Tipologia::class)->fetchById($row['tipologia']);
$model->cantidad = $row['cantidad'];
$model->elemento = $this->getMapper(TipoElemento::class)->fetchById($row['elemento']);
return $model;
}
public function save(Model $model): bool
{
// TODO: Implement save() method.
}
public function fetchByPTU(int $ptu_id): array
{
$qb = $this->connection->createQueryBuilder()
->select('tt.*')
->from($this->table, 'tt')
->innerJoin('tt', 'tipo_elemento', 'te', 'te.id = tt.elemento')
->where('tt.tipo = ?')
->orderBy('te.orden');
return array_map([$this, 'load'], $this->connection->executeQuery($qb, [$ptu_id])->fetchAllAssociative());
}
}