<?php
require 'model/MNative';


class TourMap{
    function TourMap(){
	
        //$model=new MNative('TourMap');
	//var_dump($model->list_tables());
	//var_dump($model->list_databases());
	/*
	Model toolkit testing:
	if($model->create_db('nueva_base_datos_creada'))
		echo 'return true';
	//You can see this new database created on your databases manager
	if($model->change_db('nueva_base_datos_creada'))
		echo 'return true';
	//Watch that if db change, next querys don't work because these pretend execute over mapa_buscador database
	if($model->create_table('nueva_tabla_creada'))
		echo 'return true';
	//You can see this new table created on your databases manager
	if($model->close_connection('mysql'))
		echo 'return true';
	//Watch that if db is closed, next querys don't work because these pretend execute over a connection
	*/
	
	/*
	Select query testing:
	$query_sentence='select * from Provincia';
	$query=$model->select($query_sentence);
	$result='';
	if(($query!==NULL) && (count($query)>0)){
		$length=count($query);
		for($i=0;$i<$length;$i++){
			$result.="<br/>Provincia: ".$query[$i]->provincia.' , Mapa: '.$query[$i]->ruta_mapa; 
			//var_dump($query[$i]->info->provincia);
			//var_dump($query[$i]->info->ruta_mapa);
		}
		echo 'resultado: '.$result;

		$model->close_connection();
	}
	else if($result===NULL)//if  $query is null
		$model->show_error();
	else{// if query length is 0: count($query)==0
		$model->show_advise();
		$model->close_connection();
	}
	*/

	/*
	Action querys testing
	//$query_sentence='alter table Provincia modify ruta_mapa varchar(1222) not null after provincia';
	//$query_sentence='delete from Provincia';
	//$query_sentence='update Provincia set provincia=\'ose\', ruta_mapa=\'4\' where provincia=\'ose\'';
	//$query_sentence='insert into Provincia values (\'ose\',\'5.png\')';
	$num_rows_modified=$model->action($query_sentence);
	
	if($num_rows_modified>=0){
		$model->show_advise();
		$model->close_connection();
	}
	else
		$model->show_error();
	*/
	/*
	Prepared select query testing
	$query_sentence='select * from Provincia where provincia=?';
	$model->set_prepared_select($query_sentence,'provincia');
	$params_array=array();
	$params_array[0]='ourense';
	$query=$model->prepared_select_query('provincia',$params_array,2);
	if(($query!=null) && (count($query)>0)){
		$result='';
		$length=count($query);
		$length2;
		for($i=0;$i<$length;$i++){
			$result.=$i>0?'Another row result:':'First row result:';
			$length2=count($query[$i]);
			for($y=0;$y<$length2;$y++){
				if($query[$i][$y]!=NULL)
					$result.='<br>&nbsp;&nbsp;&nbsp;&nbsp;'.($y>0?'First column: ':'Another column: ').$query[$i][$y];
			}
		}
		echo $result;
	}
	else if(!is_array($query))//if  $query is null
		$model->show_error();
	else{// if query length is 0: count($query)==0
		$model->show_advise();
		$model->close_connection();
	}
	*/

	/*
	Prepared action query testing*/
	/*	
	$query_sentence='insert into Provincia values (?,?)';
	$model->set_prepared_action($query_sentence,'provincia');
	$params_array=array();
	$params_array[0]='xxee';
	$params_array[1]='2';
	*/
	
	/*	
	$query_sentence='update Provincia set provincia=\'gg\' where provincia=?';
	$model->set_prepared_action($query_sentence,'provincia');
	$params_array=array();
	$params_array[0]='g';
	$query=$model->prepared_action_query('provincia',$params_array,0);
	if($query>0){
		$id=$model->last_inserted_id();
		echo '<p>Number of results: '.$query.'</p><p>Last inserted id: '.$id;
		if($id<=0)
			$model->show_advise();
	}
	else{
		$model->show_advise();
		$model->show_error();
	}
	*/
	
    }
}

//End of file test
//Path of the file: /test

