<?php
Class Api extends Controller{

	function __construct(){
		parent::__construct();
	}
	
	function index(){
		$this->view->render('views/index/index.php',true);
	}
	
	function getData($data, $function = false){
		$this->{$function}($data);
	}
	
	
	function loadNewDatabase($data){
		if(isset($_POST['name'])){
			$this->model->loadNewDatabase($data);
		}
	}
	
	function getSetAvailableDatabase($data){
		$data = $this->model->getSetAvailableDatabase($data);
		
		$database[] = GENERATEDDATABASEUSER_PRE.$data->databaseName;
		
		echo json_encode((object)$database);
	}
}