<?php
/*
not multi query for security, one query per time
not persistent connections for bettter performance
to call a sql procedure or function, must be used the select or prepared select (set_prepared_select before) methods
modify columns only with action method (no prepared)
*/
    class Model{
        protected $connection;
        protected $error;
	protected $advise;
	protected $prepared_select;
	protected $prepared_action;
	protected $last_insertion_id;

	function get_connection(){
		return $connection;
	}
	/*------------from interface--------------*/
	function get_error(){
		return $this->error->__toString();
	}
	function show_error(){
		die($this->error->__toString());
	}
	function show_advise(){
		echo $this->advise;
	}
	function write_error(){
		$this->error->write_log();
	}
	/*----------------------------------------*/
	function set_prepared_select($query_sentence,$name){
		$this->prepared_select[$name]=$query_sentence;
	}
	function set_prepared_action($query_sentence,$name){
		$this->prepared_action[$name]=$query_sentence;
	}
	function __construct($server,$user,$password,$db_name,$port){
		$this->error=new Error(' ');
		$this->advise=new Advise(' ');
		$this->prepared_select=array();
		$this->prepared_action=array();
        }
	function prepared_select_query($query_name,$params_array,$number_results){
		//better performance compared to the action or select methods
		$this->error->add('Non defined "prepared_selecct" method','Go to the object which belongs to the '.get_class($this).'  class.');
		$this->show_error();
	}
	function prepared_action_query($query_name,$params_array,$number_results){
		//better performance compared to the action or select methods
		$this->error->add('Non defined "prepared_action" method','Go to the object which belongs to the '.get_class($this).'  class.');
		$this->show_error();
	}
	function action($query_sentence){
		$this->error->add('Non defined "action" method','Go to the object which belongs to the '.get_class($this).'  class.');
		$this->show_error();
	}
	function select($query_sentence){
		$this->error->add('Non defined "select" method','Go to the object which belongs to the '.get_class($this).'  class.');
		$this->show_error();
	}
	/*-------------------------------toolkit methods--------------------------------*/
	function close_connection(){
		$this->error->add('Non defined "close_connection" method','Go to the object which belongs to the '.get_class($this).'  class.');
		$this->show_error();
	}
	function change_db($new_db_name){
		$this->error->add('Non defined "change_db" method','Go to the object which belongs to the '.get_class($this).'  class.');
		$this->show_error();
	}
	function list_tables(){
		$this->error->add('Non defined "list_tables" method','Go to the object which belongs to the '.get_class($this).'  class.');
		$this->show_error();
	}
	function list_databases(){
		$this->error->add('Non defined "list_databases" method','Go to the object which belongs to the '.get_class($this).'  class.');
		$this->show_error();
	}
	function create_db($db_name){
		$this->error->add('Non defined "create_db" method','Go to the object which belongs to the '.get_class($this).'  class.');
		$this->show_error();
	}
	function create_table($table_name){
		$this->error->add('Non defined "create_table" method','Go to the object which belongs to the '.get_class($this).'  class.');
		$this->show_error();
	}
	function last_inserted_id(){
		$this->error->add('Non defined "last_inserted_id" method','Go to the object which belongs to the '.get_class($this).'  class.');
		$this->show_error();
	}
    }


//End of Model file
//Path: model/Model
