<?php
class Configuracion extends AppObjeto{
	
	public $idConfiguracion;
	public $nombre;
	public $value;
	

	
	protected static $_aliasTabla = 'a';
	protected static $_nombreTabla = 'configuracion';
	protected static $_campoPK = 'idConfiguracion';
	
	public static function getByName($name){
		$select = self::selectObjeto();
		$select->where('nombre = ?',$name);
		$row = self::selectExecute($select,null, true)->getRegistroToArray();
		if (isset($row['idConfiguracion']))
			return $row;
		else
			return false;
	}
	
	public static function get($name){
		$fila = self::getByName($name);
	
		if($fila === false){
			return '';
		}else{
			return $fila['value'];
		}
	
	}
	
	public static function set($name, $value){
		$fila = self::getByName($name);
	
		if($fila === false){
			$configuracion = new Configuracion();
			
		}else{
			$configuracion = new Configuracion($fila[self::nombreId()]);
			
		}
		$configuracion->nombre = $name;
		$configuracion->value = $value;
		$configuracion->save();
		if(isset($configuracion->id) && $configuracion->id)
			return true;
		else
			return false;
	}
	
	
	
}