X-Git-Url: https://git.llucax.com/mecon/ai.git/blobdiff_plain/493cf2effdb418f10f2ae77cec0786c5cef0bbcc..beb4f27c0f38e10c639f5ec2000a0ac57719221c:/lib/AI/Servicio.php?ds=inline diff --git a/lib/AI/Servicio.php b/lib/AI/Servicio.php index 9fb5e8c..29f2070 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, A.nombre"; } elseif ($orden === AI_SERVICIO_ORDEN_LONG_NOMBRE) { $query = " SELECT *