FIX: Busqueda no funcionaba

This commit is contained in:
Juan Pablo Vial
2025-04-09 09:29:53 -04:00
parent 3c2b486083
commit bc49ba7629
2 changed files with 11 additions and 7 deletions

View File

@ -575,7 +575,11 @@ class Venta extends Ideal\Repository
protected function fetchId(string $query, ?array $data = null): array
{
try {
return $this->connection->execute($query, $data)->fetch(PDO::FETCH_ASSOC);
$result = $this->connection->execute($query, $data)->fetch(PDO::FETCH_ASSOC);
if ($result === false) {
throw new Implement\Exception\EmptyResult($query);
}
return $result;
} catch (PDOException $exception) {
throw new Implement\Exception\EmptyResult($query, $exception);
}

View File

@ -163,7 +163,7 @@ class Unidad extends Ideal\Repository
$subQuery = $this->connection->getQueryBuilder()
->select('ep1.*')
->from('estado_precio ep1')
->joined("($subSubQuery) ep0 ON ep0.id = ep1.id");
->joined("INNER JOIN ($subSubQuery) ep0 ON ep0.id = ep1.id");
$query = $this->connection->getQueryBuilder()
->select('unidad.id AS id, unidad.descripcion AS descripcion')
->columns('proyecto.id AS proyecto_id, proyecto.descripcion AS proyecto_descripcion')
@ -171,11 +171,11 @@ class Unidad extends Ideal\Repository
->columns('ptu.m2 + ptu.logia + ptu.terraza AS superficie')
->columns('precio.valor AS precio')
->from($this->getTable())
->joined('JOIN proyecto_tipo_unidad ptu ON ptu.id = unidad.pt')
->joined('JOIN proyecto ON proyecto.id = ptu.proyecto')
->joined('JOIN tipo_unidad tu ON tu.id = ptu.tipo')
->joined('JOIN precio ON precio.unidad = unidad.id')
->joined("JOIN ({$subQuery}) ep ON ep.precio = precio.id")
->joined('INNER JOIN proyecto_tipo_unidad ptu ON ptu.id = unidad.pt')
->joined('INNER JOIN proyecto ON proyecto.id = ptu.proyecto')
->joined('INNER JOIN tipo_unidad tu ON tu.id = ptu.tipo')
->joined('LEFT OUTER JOIN precio ON precio.unidad = unidad.id')
->joined("LEFT OUTER JOIN ({$subQuery}) ep ON ep.precio = precio.id")
->where('unidad.id = ?')
->group('unidad.id');
return $this->connection->execute($query, [$unidad_id])->fetch(PDO::FETCH_ASSOC);