[Cartoweb-users] Plugin search problem : misconfiguration or framewok problem

thomas gratier thomas.gratier at gmail.com
Tue May 27 03:08:28 EDT 2008


Hello all,

I need some help. I'm configuring "basic usage" of the search plugin and I
encounter this message

CartoWeb version: 3.4.0 [$Revision: 1.7 $]
class:   CartocommonException
message:   Failed executing total SQL query Message: DB Error: unknown
error  Userinfo: SELECT COUNT(*) FROM () [nativecode=ERROR:  subquery in
FROM must have an alias
HINT:  For example, FROM (SELECT ...) [AS] foo.]
Backtrace:

file: 342 - C:\ms4w\apps\cartoweb3\plugins\search\common\Search.php
call: Utils::checkDbError(Object(DB_Error), "Failed executing total SQL
query")

file: 269 - C:\ms4w\apps\cartoweb3\plugins\search\client\ClientSearch.php
call: DbResultProvider->getResult(Object(SearchRequest))

file: 265 - C:\ms4w\apps\cartoweb3\client\ClientPluginHelper.php
call: ClientSearch->initializeResult(Null)

file: UNKNOWN - UNKNOWN
call: ServerCallerHelper->initializeResultHelper(Object(ClientSearch),
Object(MapResult))

....

This message seems to say for the count in Search.php I need to add an "as
foo" at line 342 but I'm not supposed to touch this code : I suppose it
works. (If I correct it, it doesn't work too: the GUI plugin search stop)

Someone got an idea about my problem. Does it come from from my
configuration files or from a bug from the framework.
You'll find below my configuration files search.ini, search.tpl,
Search.ajax.js, search_results.tpl and my *.map

I've activated search plugins on both side (server and client), I've
inserted the code for the tpl and the ajax in cartoclient.tpl

############## search.ini #########################

;name search configuration
dsn = pgsql://user_name:password@localhost:5432/database_name
encodingContext = search_parc
config.parc_2.provider.type = fulltextTable
config.parc_2.provider.table = parc_2
config.parc_2.provider.aliases =
idnum,idnum,ident,ident,feuille,feuille,co_se_fe,co_se_fe,lieudit,lieudit,tex2,tex2,idu,idu,nature,nature,classe,classe,tex,tex,codm,codm,coar,coar,supf,supf,indp,indp,ncompte,ncompte,proprio,proprio,surf_gra,surf_gra,ctr_surf,ctr_surf,cad_dif,cad_dif,insee,insee,comparc,comparc,touche,touche,grpro,grpro,commune,commune,numprop,numprop,trouv,trouv,plu,plu
config.parc_2.provider.id = gid
config.parc_2.provider.columns = gid,ident,ncompte,proprio,
config.parc_2.provider.fulltextColumns = ident,ncompte,proprio
config.parc_2.provider.sortColumn = ident
config.parc_2.provider.sortDirection = asc
config.parc_2.provider.sortPriorities = ident, ncompte, proprio
config.parc_2.provider.labels =  ident, proprio
config.parc_2.formatter.type = smarty
config.parc_2.formatter.template = search_results

############## client.ini #########################

;!!!Do not edit this file, it is generated. Edit the .in instead!!!
cartoclientBaseUrl = "http://www.i-sig.biz:8080/cartoweb3/htdocs"
profile = development


ajaxOn = true
mapId = chapareillan

;Set encoding for files

EncoderClass.search_parc = EncoderISO

showProjectChooser = false

; ## Plugins ##

loadPlugins = layerReorder,edit,auth,locate,search

toolbarRendering = outline

langList =

toolPickerOn = true

viewOn = true
viewStorage = file
viewablePlugins = layers,query,edit,auth,search
viewMetas = author
viewAuth = all

############## extract of myproject.map #########################

LAYER
  STATUS ON
    NAME "parc_2"
    TYPE POLYGON
    CONNECTIONTYPE postgis
    CONNECTION "user=user_name password=password host=localhost
dbname=database_name"
    DATA "the_geom from (select * from parc_2) as foo USING UNIQUE gid USING
SRID=27572"
    TEMPLATE "ttt"
    METADATA
      "wms_title" "parc_2"
      "exported_values" "recenter_name_string,id_attribute_string"
      "recenter_name_string" "ident"
      "id_attribute_string" "gid|string" # query
      "query_returned_attributes" "gid idnum ident feuille co_se_fe lieudit
tex2 idu nature classe tex codm coar supf indp ncompte proprio surf_gra
ctr_surf cad_dif insee comparc touche grpro commune numprop trouv"
    END
    STATUS DEFAULT
    TRANSPARENCY 100
    PROJECTION
    'init=epsg:27572'
    END
    CLASS
       NAME 'parc_2'
       STYLE
         SYMBOL 0
         SIZE 10
         OUTLINECOLOR 0 0 0
         COLOR 255 255 255
       END
    END
  END

############## search.tpl #########################

<div id="search_div">
        <fieldset><legend>{t}Recherche parcellaire{/t}</legend> <br/>
            <table width="100%">
                <tr>
                    <td>
                      {t}Parcelle: {/t}
                    </td>
                    <td>
                        <input type="text" id="search_ident"
                          name="search_ident" size="13"/>
                    </td>
                </tr>
                <tr>
                    <td>
                        {t}Proprietaire par compte: {/t}
                    </td>
                    <td>
                        <input type="text" id="search_ncompte"
                          name="search_ncompte" size="13"/>
                    </td>
                </tr>

                <tr>
                    <td>
                        {t}Proprietaire par nom: {/t}
                    </td>
                    <td>
                        <input type="text" id="search_proprio"
                          name="search_proprio" size="13"/>
                    </td>
                </tr>



            </table>
            <p>


              <input type="submit" value="{t}Search{/t}" class="form_button"
               onclick="javaScript: CartoWeb.trigger('Search.DoIt'); return
false;"/>

              <input type="hidden" id="search_config" name="search_config"
value="parc_2" />
              <input type="hidden" id="search_sort_column"
name="search_sort_column" value="ident"/>
              <input type="hidden" id="search_sort_direction"
name="search_sort_direction" value="asc" />
              <input type="hidden" id="search_number" name="search_number"
value="10"/>


              <div id="search_results_div"></div>
            </p>
        </fieldset>
    </div>

############## search_results.tpl #########################

{if $table->numRows > 0}
     <table class="yourCssClass">
         <tr>
            <th>{t}Id{/t}</th>
            {foreach from=$table->columnIds item=column}
            <th> <a href="JavaScript:
order('{$column}');">{t}{$column}{/t}</a></th>
            {/foreach}
         </tr>

         {foreach from=$table->rows item=row}
         <tr>
            <td>{$row->rowId}</td>
            {foreach from=$row->cells item=value}
            <td><a href="JavaScript:
recenter('{$row->rowId}');">{$value}</a></td>
            {/foreach}
         </tr>
         {/foreach}

     </table>

{else}
     {t}No results{/t}
{/if}

############## Search.ajax.js #########################

AjaxPlugins.Search = {

    handleResponse: function(pluginOutput) {
        //should be the same value as the input search_config
        if (pluginOutput.htmlCode.parc_2)
            $('search_results_div').innerHTML =
pluginOutput.htmlCode.parc_2;


    }
};

    /*
    * Search plugin's Actions
    */

    AjaxPlugins.Search.Actions = {};

    AjaxPlugins.Search.Actions.DoIt = {

      buildPostRequest: function(argObject) {
        return AjaxHandler.buildPostRequest();
      }
    };

    function order(column) {

      if (column != $('search_sort_column').value) {
        $('search_sort_column').value = column;
        $('search_sort_direction').value = 'asc';
      } else {
        if ($('search_sort_direction').value == 'asc') {
        $('search_sort_direction').value = 'desc';
        } else {
        $('search_sort_direction').value = 'asc';
        }
      }

      CartoWeb.trigger('Search.DoIt')
    }

    function recenter(id){
      if ($('search_config').value == 'parc_2') {
        //id to recenter, be sure there is a hidden input with that name and

        //id in your template! if not, add it
        $('id_recenter_ids').value = id;

        /* if the search database table name is the same as the related
layer
        to recenter on, you can set it as below
        be sure there is a hidden input with that name and id in your
template!
        if not, add it */
        $('id_recenter_layer').value = $('search_config').value;

        /* do not use the recenter_scale parameter if you recenter on ids,
        only use it with recenter on x,y.
        you can set the recenter scale in location.ini on server side */

        /* do not use the recenter_doit parameter if you recenter on ids,
        only use it with recenter on x,y. */

        CartoWeb.trigger('Location.Recenter');
      }
    }

    function search(config) {

    $('search_config').value = config;
    if (config == 'parc_2') {
        $('search_number').value = 10;
    }

    CartoWeb.trigger('Search.DoIt');


Thanks for any help

Thomas G
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.maptools.org/pipermail/cartoweb-users/attachments/20080527/cdd9736e/attachment.html


More information about the Cartoweb-users mailing list