From da51d7f6085a1f40e5869aacbbcfabc2efc881e1 Mon Sep 17 00:00:00 2001 From: Leandro Lucarella Date: Wed, 8 Oct 2003 21:58:34 +0000 Subject: [PATCH 1/1] Se mejora un poco el orden por longitud de hijos. --- lib/AI/Servicio.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/AI/Servicio.php b/lib/AI/Servicio.php index 9fb5e8c..d6277cf 100644 --- a/lib/AI/Servicio.php +++ b/lib/AI/Servicio.php @@ -190,7 +190,10 @@ class AI_Servicio extends AI_DBTreeObject { $id = intval($this->$id_field); if ($orden === AI_SERVICIO_ORDEN_LONG_HIJOS) { $query = " - SELECT A.*, SUM(CEIL(LENGTH(B.nombre) / 22)) as RENGLONES + SELECT + A.*, + count(1) as COUNT, + SUM(CEIL(LENGTH(B.nombre) / 22)) as RENGLONES FROM {$this->conf['base']}.{$this->conf['tabla']} AS A, {$this->conf['base']}.{$this->conf['tabla']} AS B WHERE A.$id_field = B.$id_padre @@ -198,7 +201,9 @@ class AI_Servicio extends AI_DBTreeObject { if ($soloHabilitados) { $query .= " AND A.{$this->conf['habilitado']} = 1"; } - $query .= " GROUP BY A.$id_field ORDER BY RENGLONES DESC"; + $query .= " + GROUP BY A.$id_field + ORDER BY RENGLONES DESC, COUNT DESC"; } elseif ($orden === AI_SERVICIO_ORDEN_LONG_NOMBRE) { $query = " SELECT * -- 2.43.0