Hi,

I' am trying to get a drop-down list for search, sorted by descending order:

=====
        <searchitem name="RegistoProcessosObra" description="Processos de Obra">
            <layer type="postgis" name="RegistoProcessosObra">
                                <field type="n" name="proc_ano" 
description="Ano" wildcard="2">
                                        <definition type="options" 
connectiontype="db" sort="desc">
                                                <dsn 
encoding="UTF-8">pgsql://zemacau:z53498k@10.27.2.24/pmapper</dsn>
                                                <sql>SELECT DISTINCT proc_ano, 
proc_ano FROM p_obra WHERE proc_ano IS
NOT NULL ORDER BY proc_ano</sql>
                                        </definition>
                                </field>                                
                                <field type="n" name="proc_numero" 
description="Número" wildcard="2" />
                                <field type="s" name="cod_edificio" 
description="Código Edifício"
wildcard="0" />
            </layer>
        </searchitem>           
=====

But it seems to me that the option SORT in the search.xml file is ignored by
the search.php file...

pm_debug.log shows me that information:

=====
[29-Oct-2015 14:20:04] P.MAPPER debug info
XML->//definition
 SimpleXMLElement Object
(
    [@attributes] => Array
        (
            [type] => options
            [connectiontype] => db
            [sort] => desc
        )

    [dsn] => pgsql://zemacau:z53498k@10.27.2.24/pmapper
    [sql] => SELECT DISTINCT proc_ano, proc_ano FROM p_obra WHERE proc_ano
IS NOT NULL ORDER BY proc_ano
)

[29-Oct-2015 14:20:04] P.MAPPER debug info
search.php->getOptionsFromDb()
 SELECT DISTINCT proc_ano, proc_ano FROM p_obra WHERE proc_ano IS NOT NULL
ORDER BY proc_ano
[29-Oct-2015 14:20:04] P.MAPPER debug info
search.php->getOptionsFromDb()->json
 { "1960":"1960", "1961":"1961", "1962":"1962", "1963":"1963",
"1964":"1964", "1967":"1967", "1969":"1969", "1970":"1970", "1972":"1972",
"1975":"1975", "1979":"1979", "1984":"1984", "1985":"1985", "1986":"1986",
"1987":"1987", "1988":"1988", "1989":"1989", "1990":"1990", "1991":"1991",
"1992":"1992", "1993":"1993", "1994":"1994", "1995":"1995", "1996":"1996",
"1997":"1997", "1998":"1998", "1999":"1999", "2000":"2000", "2001":"2001",
"2002":"2002", "2003":"2003", "2004":"2004", "2005":"2005", "2006":"2006",
"2007":"2007", "2008":"2008", "2009":"2009", "2010":"2010", "2011":"2011",
"2012":"2012", "2013":"2013", "2014":"2014", "2015":"2015"}
=====

If i force the SELECT in search.xml file with DESC, like this:

<sql>SELECT DISTINCT proc_ano, proc_ano FROM p_obra WHERE proc_ano IS NOT
NULL ORDER BY proc_ano DESC</sql>

the pm_debug.log shows me the coorect information:

=====
XML->//definition
 SimpleXMLElement Object
(
    [@attributes] => Array
        (
            [type] => options
            [connectiontype] => db
            [sort] => desc
        )

    [dsn] => pgsql://zemacau:z53498k@10.27.2.24/pmapper
    [sql] => SELECT DISTINCT proc_ano, proc_ano FROM p_obra WHERE proc_ano
IS NOT NULL ORDER BY proc_ano DESC
)

[29-Oct-2015 14:27:18] P.MAPPER debug info
search.php->getOptionsFromDb()
 SELECT DISTINCT proc_ano, proc_ano FROM p_obra WHERE proc_ano IS NOT NULL
ORDER BY proc_ano DESC
[29-Oct-2015 14:27:18] P.MAPPER debug info
search.php->getOptionsFromDb()->json
 { "2015":"2015", "2014":"2014", "2013":"2013", "2012":"2012",
"2011":"2011", "2010":"2010", "2009":"2009", "2008":"2008", "2007":"2007",
"2006":"2006", "2005":"2005", "2004":"2004", "2003":"2003", "2002":"2002",
"2001":"2001", "2000":"2000", "1999":"1999", "1998":"1998", "1997":"1997",
"1996":"1996", "1995":"1995", "1994":"1994", "1993":"1993", "1992":"1992",
"1991":"1991", "1990":"1990", "1989":"1989", "1988":"1988", "1987":"1987",
"1986":"1986", "1985":"1985", "1984":"1984", "1979":"1979", "1975":"1975",
"1972":"1972", "1970":"1970", "1969":"1969", "1967":"1967", "1964":"1964",
"1963":"1963", "1962":"1962", "1961":"1961", "1960":"1960"}
=====

But the drop-down list appears always sorted in ascending order... 
<http://pmapper-users-p-mapper-users-mailing-list.993774.n3.nabble.com/file/n4025805/dropdownlist.jpg>
 

I think this is a pmapper bug...

Can anyone help me, please?
Thanks in advance




--
View this message in context: 
http://pmapper-users-p-mapper-users-mailing-list.993774.n3.nabble.com/pmapper-4-3-2-search-in-postgis-with-option-sort-desc-tp4025805.html
Sent from the pmapper-users -- p.mapper users mailing list mailing list archive 
at Nabble.com.

------------------------------------------------------------------------------
_______________________________________________
pmapper-users mailing list
pmapper-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pmapper-users

Reply via email to