<?php

Class Controller extends AppObjeto{
	
	public $id_controller;
	public $nombre;
	//Configuración de tabla
	

	protected static $_aliasTabla = 'a';
	protected static $_nombreTabla = 'controller';
	protected static $_campoPK = 'id_controller';
	
	
	public static function getAll($parametros = array()){
		$select = self::selectObjeto();
		$res = self::selectExecute($select, $parametros);
		return $res;
	}
	

	public static function loadByNombre($nombre){
		$select = self::select();
		$select->where('nombre= ?', $nombre);
		$result = self::fetchRow($select);
		if(count($result)>0){
			$controller = new Controller($result[self::$primary]);
		}else{
			$controller = new Controller();
			$controller->nombre = $nombre;
			$controller->save();
		}
		return $controller;
	}
	public function tieneVista($accion){
		return Vista::loadByNombre($accion, $this->id);
	}
	
	public static function loadSelect(){
		$lista_resutlado = self::loadAll();
		$salida = array();
		foreach ($lista_resutlado as $resultado){
			$salida[$resultado[self::$primary]] = $resultado['nombre'];
		}
		return $salida;
	}
}