prepare("SELECT COUNT(*) FROM exam_tipos $wSql"); $s->execute($params); $total = (int)$s->fetchColumn(); $s = $pdo->prepare( "SELECT id, codigo, nombre, categoria, activo, cups, seremite, cod_protocolo, tipo_muestra FROM exam_tipos $wSql ORDER BY categoria, nombre LIMIT $limit OFFSET $offset" ); $s->execute($params); jsonOk(['data' => $s->fetchAll(PDO::FETCH_ASSOC), 'total' => $total, 'page' => $page, 'limit' => $limit]);