I: R: [Cartoweb-users] list in cartoweb HELP!!!!!!!!!!

Giovanni Virdis g.virdis at riteco.it
Thu Jun 12 06:48:41 EDT 2008


Can someone help me


-----Messaggio originale-----
Da: Giovanni Virdis 
Inviato: giovedì 12 giugno 2008 11.50
A: 'Fabio D'Ovidio'
Oggetto: R: R: [Cartoweb-users] list in cartoweb HELP!!!!!!!!!!

Excuse me Fabio , I'm not explain. This is my situation

----------------------------------------------------------------------------
ClientEdit.php:

public function renderForm(Smarty $template) {
		
		
		$template->assign('first_query',$this->query_sql());
}

//Questa funzione esegue una query e restituisce il resulset con i valori	
	  public function query_sql()
	  {
       // $this->dati = array();
		
       //Prendo la connessione 
        $db = $this->getDb();
       //Creo la query
        $sql = 'SELECT id_funuso,ds_funuso FROM ppc_funuso';
       //Eseguo la query e assegno i valori al resultset       
	    $result = $db->query($sql);
       
	   return $ result;
	}

   //Questa funzione restituisce la connessione al database	
    private function getDb() {
	
	//Prendo il dsn
     $dsn = "pgsql://iwork_ppc:colapasta@10.0.0.3/iwork_ppc";
      // $dsn = $this->getConfig()->databaseDsn;         
    
	//Se il dsn è vuoto    
     if (!$dsn) {
      throw new CartoclientException('DSN non valido');
	 }
    
    //Creo la connessione al database
	  $this->db = DB::connect($dsn);
    //Se la connessione viene esguita con problemi  
	 if (DB::isError ($this->db))
      die ("Impossibile connettersi: " . $this->db->getMessage () . "\n");

    //Restituisco la connessione
	 return $this->db;
	 
    }

----------------------------------------------------------------------------

Cartoclient.tpl:

<script language="JavaScript" type="text/javascript">
    <!--	 
     funUsoListCo ='{$first_query}';
    //-->
  </script>

---------------------------------------------------------------------------

dhtmlEdit.js:

Map.prototype.editTableAddRow = function(table, aFeature) {
  debugger;
  for (var k = 0; k < funUsoListCo.length; k++){
	     var vfuListCod = funUsoListCo[k];
  }
.....
}

When I debug funUsoListCo is a string and is value is "Array" Why? In funUsoListCo I must have the array of value from db?

Thanks


-----Messaggio originale-----
Da: Fabio D'Ovidio [mailto:fabiodovidio at gmail.com] 
Inviato: giovedì 12 giugno 2008 11.01
A: Giovanni Virdis
Cc: Cartoweb Users
Oggetto: Re: R: [Cartoweb-users] list in cartoweb HELP!!!!!!!!!!

Hi Giovanni!
May be you must consider Sessionable Interface in you 
ClientYourNamePlugin.php ($comune will be tour variable):


// my data structure to be stored
class ResultFromDataBase {   
    public  $comune = array();

}

// Sessionable interface

    public function createSession(MapInfo $mapInfo,
                                  InitialMapState $initialMapState) {
        
        $this->ResultFromDataBase = new ResultFromDataBase();
        $this->clearSession();      
        return;
    }
 

   public function saveSession() {
   
        return $this->ResultFromDataBase;
    } 
   
    public function loadSession($sessionObject) {
   
        $this->ResultFromDataBase = $sessionObject;
    }
   
    protected function clearSession() {
    $this->ResultFromDataBase->comune = '';
   
   
    }




Giovanni Virdis ha scritto:
>
> Hi Fabio,
>
>  
>
> I have made what you have said to me. I get the value from db with the 
> function query_sql() that return a resultset but when I get the smarty 
> variable 'first_query' this is empty but in the resultset there are 
> the value . Why? Where I wrong?
>
> This is the function that return a fill load resulset.
>
> Please help if you can
>
> Thanks
>
>  
>
>  
>
>  
>
> ------------------------------------------------------------------------
>
> *Da:* Fabio D'Ovidio [mailto:fabiodovidio at gmail.com]
> *Inviato:* mercoledì 11 giugno 2008 8.16
> *A:* Giovanni Virdis
> *Cc:* cartoweb-users at lists.maptools.org
> *Oggetto:* Re: [Cartoweb-users] list in cartoweb HELP!!!!!!!!!!
>
>  
>
> Giovanni,
> IMHO you must modify your PHP source code in order to do what you want.
>
> In the ClientYourPluginName.php file you could modify as following:
>
> public function renderForm(Smarty $template) {
>     
> ......   
>    
>      $template->assign('first_query', $this->query_sql());
>     
> ...
> ...    
>     
> }
>
> where query_sql() is the function that queries your database and 
> return resultset (you can look at here: 
> http://www.cartoweb.org/cwiki/HowToDisplayOnTheMapAPointFromADatabaseQuery). 
> Remeber Cartoweb uses PEAR extension to connect and query DB...
> After you can call the variable "first_query" from your application 
> cartoclient.tpl file (so you must modify it. Remeber to make a --clean 
> after deploying cartoweb). All values can be put in the 
> YourPluginName.tpl file where a  <select></select> section is just 
> prepared or you can create YourPluginName.tpl file dinamically 
> inserting you values..
>
> In order to select a second value coming from the choise of the first 
> one, you have to create an "onchage" event on the first select item in 
> order to fetch the value and make the second query...
>
> Fabio D'Ovidio
>
> 2008/6/10 Giovanni Virdis <g.virdis at riteco.it 
> <mailto:g.virdis at riteco.it>>:
>
> Can someonehelp me . I post  my answer many times but nobody help me. 
> Please I'm new and I need help
>
>  
>
> Hi,
>
> if is possibile i want populate the select item from db. I have modify 
> the dhtmlEdit.js file to show a select item with a fix value
>
>  
>
> var authorisedOptionsList = new Array(1, 2, 3);
>
> var authorisedOptionsListLabel = new Array('Strutture pubbliche', 
> 'Strutture per il commercio', 'Strutture militari');
>
>  
>
> How i can populate this item  by db select?
>
>  Is possible chanche the value of second select item when I change the 
> value of first select item ?
>
> Example
>
>  
>
> 1° Select value:
>
>  
>
> 1, 'America'
> 2, 'Europa'
>
> 3, 'Asia'
>
> 4, 'Oceania'
>
> 5, 'Africa'
>
>  
>
> 2° Select value:
>
>  
>
> 1, 'Giappone'
> 2, 'Cina'
> 3, 'Mongolia'
> 4, 'Stati Uniti'
> 5, 'Canada'
> 6, 'Messico'
> 7, 'Italia'
> 8, 'Spagna'
>
>  
>
>  
>
>
> _______________________________________________
> Cartoweb-users mailing list
> Cartoweb-users at lists.maptools.org 
> <mailto:Cartoweb-users at lists.maptools.org>
> http://lists.maptools.org/mailman/listinfo/cartoweb-users
>
>  
>

-- 
Ing. Fabio D'Ovidio

INOVA Open Solutions s.r.l.
Web : http://www.inovaos.it
Tel.: 081 197 57 600
mail: fabiodovidio at gmail.com






More information about the Cartoweb-users mailing list