<?php
require_once 'pdoparameters.php';
/*
*@Autor DNDSIT 
*/
class PDOCONTROLLER{
	/*private $cadenaconex;
	private $conex;
	
	public function __construct(){
		$conex = $this->connectDB();
		if(!empty($conex)) {
			$this->conex = $conex;			
		}
		
	}

	function connectDB() {
		try{
			$this->cadenaconex="mysql:host=".DB_SERVER.";port=".DB_PORT.";dbname=".DB_DBNAME.";charset=".DB_CHARSET;
			$options=[
				PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
				PDO::ATTR_EMULATE_PREPARES => false,
			];
			$pdo = new PDO($this->cadenaconex,DB_USER,DB_PASS,$options);
			return $pdo;

		}catch(Exception $ex){
			echo "Error conexions".$ex->getMessage();
			exit;
		}

	}*/

	private $cadenaconex;
	private $conex;
	private $host = "69.197.152.107";
	private $port = "3306";
	private $user = "usufe";
	private $password = "Naty@2012*";
	private $database = "dnd";
	private $charset ="utf8";

	/*private $host = "66.70.255.14";
	private $port = "3306";
	private $user = "netempire_elsycb";
	private $password = "Tm3Y@1CtWn67";
	private $database = "netempire_elsy";
	private $charset ="utf8";*/

	public function __construct(){
		$conex = $this->connectDB();
		if(!empty($conex)) {
			$this->conex = $conex;			
		}
	}
	function connectDB() {
		try{
			$this->cadenaconex="mysql:host=".$this->host.";port=".$this->port.";dbname=".$this->database.";charset=".$this->charset;
			$options=[
				PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
				PDO::ATTR_EMULATE_PREPARES => false,
			];
			$pdo = new PDO($this->cadenaconex,$this->user,$this->password,$options);
			return $pdo;
		}catch(Exception $ex){
			echo "Error conexions".$ex->getMessage();
			exit;
		}
	}
	

	public function executeconsulta($sql="",$valores=array()){
		if($sql != "" && strlen($sql)>0){
			
			//echo json_encode($valores);
			try{
				$consulta=$this->conex->prepare($sql);
				//$consulta = $this->$conex->query($sql);
				$consulta->execute($valores);
				if(intval($consulta->errorCode())===0){
					return $consulta->fetchAll(PDO::FETCH_ASSOC);
				}else{
					return intval($consulta->errorCode());
				}
			}catch(exception $ex){
				return $ex->getMessage();
			}
		}else{
			echo "else";
			return 0;
		}
	}

	public function execute_update($sql="",$valores=array()){
		if($sql != "" && strlen($sql)>0){
			try{
				$update=$this->conex->prepare($sql);
				$update->execute($valores);
				return $update->rowCount();
				
			}catch(exception $ex){
				return $ex->getMessage();
			}
		}else{
			echo "else";
			return 0;
		}
	}

	public function execute_insert($sql="",$valores=array()){
		if($sql != "" && strlen($sql)>0){
			try{
				$insert=$this->conex->prepare($sql);
				$insert->execute($valores);
				$idinsert=$this->conex->lastInsertId();
				return $idinsert;
			}catch(exception $ex){
				return $ex->getMessage();
			}
		}else{
			echo "else";
			return 0;
		}
	}


}

class PDOECOSCORP{
	private $cadenaconex;
	private $conex;
	private $host = "69.197.152.107";
	private $port = "3306";
	private $user = "usufe";
	private $password = "Naty@2012*";
	private $database = "ecos_corp";
	private $charset ="utf8";

	public function __construct(){
		$conex = $this->connectDB();
		if(!empty($conex)) {
			$this->conex = $conex;			
		}
	}
	function connectDB() {
		try{
			$this->cadenaconex="mysql:host=".$this->host.";port=".$this->port.";dbname=".$this->database.";charset=".$this->charset;
			$options=[
				PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
				PDO::ATTR_EMULATE_PREPARES => false,
			];
			$pdo = new PDO($this->cadenaconex,$this->user,$this->password,$options);
			return $pdo;
		}catch(Exception $ex){
			echo "Error conexions".$ex->getMessage();
			exit;
		}
	}
	

	public function executeconsulta($sql="",$valores=array()){
		if($sql != "" && strlen($sql)>0){
			try{
				//echo $sql;
				$consulta=$this->conex->prepare($sql);
				$consulta->execute($valores);
				if(intval($consulta->errorCode())===0){
					return $consulta->fetchAll(PDO::FETCH_ASSOC);
				}else{
					return intval($consulta->errorCode());
				}
			}catch(exception $ex){
				return $ex->getMessage();
			}
		}else{
			echo "else";
			return 0;
		}
	}

	public function execute_insert($sql="",$valores=array()){
		if($sql != "" && strlen($sql)>0){
			try{
				$insert=$this->conex->prepare($sql);
				$insert->execute($valores);
				$idinsert=$this->conex->lastInsertId();
				return $idinsert;
			}catch(exception $ex){
				return $ex->getMessage();
			}
		}else{
			echo "else";
			return 0;
		}
	}

	public function execute_update($sql="",$valores=array()){
		// Verificar si la consulta SQL no está vacía.
		if($sql != "" && strlen($sql)>0){
			try{
				// Preparar la consulta SQL
				$update=$this->conex->prepare($sql);
				// Ejecutar la consulta con los valores proporcionados.
				$update->execute($valores);
				// Retornar el número de filas afectadas.
				return $update->rowCount();
				
			}catch (PDOException $ex) {
				// Retornar el mensaje de error en caso de excepción.
				echo $ex->getMessage();
				return $ex->getMessage();
			}
		}else{
			echo "else";
			return 0;
		}
	}


	public function execute_eliminar($sql="",$valores=array()){
		if($sql != "" && strlen($sql)>0){
			try{
				$elimina=$this->conex->prepare($sql);
				$elimina->execute($valores);
				return "procesado";
			}catch(exception $ex){
				return $ex->getMessage();
			}
		}else{
			echo "else";
			return 0;
		}
	}
}

class PDOLUCKYE{
	private $cadenaconex;
	private $conex;
	private $host = "69.197.152.107";
	private $port = "3306";
	private $user = "usufe";
	private $password = "Naty@2012*";
	private $database = "luky";
	private $charset ="utf8";

	public function __construct(){
		$conex = $this->connectDB();
		if(!empty($conex)) {
			$this->conex = $conex;			
		}
	}
	function connectDB() {
		try{
			$this->cadenaconex="mysql:host=".$this->host.";port=".$this->port.";dbname=".$this->database.";charset=".$this->charset;
			$options=[
				PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
				PDO::ATTR_EMULATE_PREPARES => false,
			];
			$pdo = new PDO($this->cadenaconex,$this->user,$this->password,$options);
			return $pdo;
		}catch(Exception $ex){
			echo "Error conexions".$ex->getMessage();
			exit;
		}
	}
	

	public function executeconsulta($sql="",$valores=array()){
		if($sql != "" && strlen($sql)>0){
			try{
				//echo $sql;
				$consulta=$this->conex->prepare($sql);
				$consulta->execute($valores);
				if(intval($consulta->errorCode())===0){
					return $consulta->fetchAll(PDO::FETCH_ASSOC);
				}else{
					return intval($consulta->errorCode());
				}
			}catch(exception $ex){
				return $ex->getMessage();
			}
		}else{
			echo "else";
			return 0;
		}
	}

	public function execute_insert($sql="",$valores=array()){
		if($sql != "" && strlen($sql)>0){
			try{
				$insert=$this->conex->prepare($sql);
				$insert->execute($valores);
				$idinsert=$this->conex->lastInsertId();
				return $idinsert;
			}catch(exception $ex){
				return $ex->getMessage();
			}
		}else{
			echo "else";
			return 0;
		}
	}

	public function execute_update($sql="",$valores=array()){
		// Verificar si la consulta SQL no está vacía.
		if($sql != "" && strlen($sql)>0){
			try{
				// Preparar la consulta SQL
				$update=$this->conex->prepare($sql);
				// Ejecutar la consulta con los valores proporcionados.
				$update->execute($valores);
				// Retornar el número de filas afectadas.
				return $update->rowCount();
				
			}catch (PDOException $ex) {
				// Retornar el mensaje de error en caso de excepción.
				echo $ex->getMessage();
				return $ex->getMessage();
			}
		}else{
			echo "else";
			return 0;
		}
	}


	public function execute_eliminar($sql="",$valores=array()){
		if($sql != "" && strlen($sql)>0){
			try{
				$elimina=$this->conex->prepare($sql);
				$elimina->execute($valores);
				return "procesado";
			}catch(exception $ex){
				return $ex->getMessage();
			}
		}else{
			echo "else";
			return 0;
		}
	}
}

class PDOJHOYOS{
	private $cadenaconex;
	private $conex;
	private $host = "ecos-spanishschool.com";
	private $port = "3306";
	private $user = "ecosspan_jhoyos";
	private $password = ",*EVk}&uVqUZ";
	private $database = "ecosspan_jhoyos";
	private $charset ="utf8";

	public function __construct(){
		$conex = $this->connectDB();
		if(!empty($conex)) {
			$this->conex = $conex;			
		}
	}
	function connectDB() {
		try{
			$this->cadenaconex="mysql:host=".$this->host.";port=".$this->port.";dbname=".$this->database.";charset=".$this->charset;
			$options=[
				PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
				PDO::ATTR_EMULATE_PREPARES => false,
			];
			$pdo = new PDO($this->cadenaconex,$this->user,$this->password,$options);
			return $pdo;
		}catch(Exception $ex){
			echo "Error conexions".$ex->getMessage();
			exit;
		}
	}
	

	public function executeconsulta($sql="",$valores=array()){
		if($sql != "" && strlen($sql)>0){
			try{
				//echo $sql;
				$consulta=$this->conex->prepare($sql);
				$consulta->execute($valores);
				if(intval($consulta->errorCode())===0){
					return $consulta->fetchAll(PDO::FETCH_ASSOC);
				}else{
					return intval($consulta->errorCode());
				}
			}catch(exception $ex){
				return $ex->getMessage();
			}
		}else{
			echo "else";
			return 0;
		}
	}

	public function execute_insert($sql="",$valores=array()){
		if($sql != "" && strlen($sql)>0){
			try{
				$insert=$this->conex->prepare($sql);
				$insert->execute($valores);
				$idinsert=$this->conex->lastInsertId();
				return $idinsert;
			}catch(exception $ex){
				return $ex->getMessage();
			}
		}else{
			echo "else";
			return 0;
		}
	}

	public function execute_update($sql="",$valores=array()){
		// Verificar si la consulta SQL no está vacía.
		if($sql != "" && strlen($sql)>0){
			try{
				// Preparar la consulta SQL
				$update=$this->conex->prepare($sql);
				// Ejecutar la consulta con los valores proporcionados.
				$update->execute($valores);
				// Retornar el número de filas afectadas.
				return $update->rowCount();
				
			}catch (PDOException $ex) {
				// Retornar el mensaje de error en caso de excepción.
				echo $ex->getMessage();
				return $ex->getMessage();
			}
		}else{
			echo "else";
			return 0;
		}
	}


	public function execute_eliminar($sql="",$valores=array()){
		if($sql != "" && strlen($sql)>0){
			try{
				$elimina=$this->conex->prepare($sql);
				$elimina->execute($valores);
				return "procesado";
			}catch(exception $ex){
				return $ex->getMessage();
			}
		}else{
			echo "else";
			return 0;
		}
	}
}

class PDOBCWEB{
	private $cadenaconex;
	private $conex;
	private $host = "ecos-spanishschool.com";
	private $port = "3306";
	private $user = "ecosspan_bc";
	private $password = "*dUE,wr{Piy#";
	private $database = "ecosspan_bc";
	private $charset ="utf8";

	public function __construct(){
		$conex = $this->connectDB();
		if(!empty($conex)) {
			$this->conex = $conex;			
		}
	}
	function connectDB() {
		try{
			$this->cadenaconex="mysql:host=".$this->host.";port=".$this->port.";dbname=".$this->database.";charset=".$this->charset;
			$options=[
				PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
				PDO::ATTR_EMULATE_PREPARES => false,
			];
			$pdo = new PDO($this->cadenaconex,$this->user,$this->password,$options);
			return $pdo;
		}catch(Exception $ex){
			echo "Error conexions".$ex->getMessage();
			exit;
		}
	}
	

	public function executeconsulta($sql="",$valores=array()){
		if($sql != "" && strlen($sql)>0){
			try{
				//echo $sql;
				$consulta=$this->conex->prepare($sql);
				$consulta->execute($valores);
				if(intval($consulta->errorCode())===0){
					return $consulta->fetchAll(PDO::FETCH_ASSOC);
				}else{
					return intval($consulta->errorCode());
				}
			}catch(exception $ex){
				return $ex->getMessage();
			}
		}else{
			echo "else";
			return 0;
		}
	}

	public function execute_insert($sql="",$valores=array()){
		if($sql != "" && strlen($sql)>0){
			try{
				$insert=$this->conex->prepare($sql);
				$insert->execute($valores);
				$idinsert=$this->conex->lastInsertId();
				return $idinsert;
			}catch(exception $ex){
				return $ex->getMessage();
			}
		}else{
			echo "else";
			return 0;
		}
	}

	public function execute_update($sql="",$valores=array()){
		// Verificar si la consulta SQL no está vacía.
		if($sql != "" && strlen($sql)>0){
			try{
				// Preparar la consulta SQL
				$update=$this->conex->prepare($sql);
				// Ejecutar la consulta con los valores proporcionados.
				$update->execute($valores);
				// Retornar el número de filas afectadas.
				return $update->rowCount();
				
			}catch (PDOException $ex) {
				// Retornar el mensaje de error en caso de excepción.
				echo $ex->getMessage();
				return $ex->getMessage();
			}
		}else{
			echo "else";
			return 0;
		}
	}


	public function execute_eliminar($sql="",$valores=array()){
		if($sql != "" && strlen($sql)>0){
			try{
				$elimina=$this->conex->prepare($sql);
				$elimina->execute($valores);
				return "procesado";
			}catch(exception $ex){
				return $ex->getMessage();
			}
		}else{
			echo "else";
			return 0;
		}
	}
}

class PDOBC{
	private $cadenaconex;
	private $conex;
	private $host = "69.197.152.107";
	private $port = "3306";
	private $user = "usufe";
	private $password = "Naty@2012*";
	private $database = "BC";
	private $charset ="utf8";

	public function __construct(){
		$conex = $this->connectDB();
		if(!empty($conex)) {
			$this->conex = $conex;			
		}
	}
	function connectDB() {
		try{
			$this->cadenaconex="mysql:host=".$this->host.";port=".$this->port.";dbname=".$this->database.";charset=".$this->charset;
			$options=[
				PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
				PDO::ATTR_EMULATE_PREPARES => false,
			];
			$pdo = new PDO($this->cadenaconex,$this->user,$this->password,$options);
			return $pdo;
		}catch(Exception $ex){
			echo "Error conexions".$ex->getMessage();
			exit;
		}
	}
	

	public function executeconsulta($sql="",$valores=array()){
		if($sql != "" && strlen($sql)>0){
			try{
				//echo $sql;
				$consulta=$this->conex->prepare($sql);
				$consulta->execute($valores);
				if(intval($consulta->errorCode())===0){
					return $consulta->fetchAll(PDO::FETCH_ASSOC);
				}else{
					return intval($consulta->errorCode());
				}
			}catch(exception $ex){
				return $ex->getMessage();
			}
		}else{
			echo "else";
			return 0;
		}
	}

	public function execute_insert($sql="",$valores=array()){
		if($sql != "" && strlen($sql)>0){
			try{
				$insert=$this->conex->prepare($sql);
				$insert->execute($valores);
				$idinsert=$this->conex->lastInsertId();
				return $idinsert;
			}catch(exception $ex){
				return $ex->getMessage();
			}
		}else{
			echo "else";
			return 0;
		}
	}

	public function execute_update($sql="",$valores=array()){
		if($sql != "" && strlen($sql)>0){
			try{
				$update=$this->conex->prepare($sql);
				$update->execute($valores);
				return $update->rowCount();
				
			}catch(exception $ex){
				return $ex->getMessage();
			}
		}else{
			echo "else";
			return 0;
		}
	}


	public function execute_eliminar($sql="",$valores=array()){
		if($sql != "" && strlen($sql)>0){
			try{
				$elimina=$this->conex->prepare($sql);
				$elimina->execute($valores);
				return "procesado";
			}catch(exception $ex){
				return $ex->getMessage();
			}
		}else{
			echo "else";
			return 0;
		}
	}
}

class PDOELPUNTOSAS{
	private $cadenaconex;
	private $conex;
	private $host = "66.70.255.14";
	private $port = "3306";
	private $user = "netempir_elpunto";
	private $password = "elpunto2018+-";
	private $database = "netempir_elpunto";
	private $charset ="utf8";

	public function __construct(){
		$conex = $this->connectDB();
		if(!empty($conex)) {
			$this->conex = $conex;			
		}
	}
	function connectDB() {
		try{
			$this->cadenaconex="mysql:host=".$this->host.";port=".$this->port.";dbname=".$this->database.";charset=".$this->charset;
			$options=[
				PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
				PDO::ATTR_EMULATE_PREPARES => false,
			];
			$pdo = new PDO($this->cadenaconex,$this->user,$this->password,$options);
			return $pdo;
		}catch(Exception $ex){
			echo "Error conexions".$ex->getMessage();
			exit;
		}
	}
	

	public function executeconsulta($sql="",$valores=array()){
		if($sql != "" && strlen($sql)>0){
			try{
				//echo $sql;
				$consulta=$this->conex->prepare($sql);
				$consulta->execute($valores);
				if(intval($consulta->errorCode())===0){
					return $consulta->fetchAll(PDO::FETCH_ASSOC);
				}else{
					return intval($consulta->errorCode());
				}
			}catch(exception $ex){
				return $ex->getMessage();
			}
		}else{
			echo "else";
			return 0;
		}
	}

	public function execute_insert($sql="",$valores=array()){
		if($sql != "" && strlen($sql)>0){
			try{
				$insert=$this->conex->prepare($sql);
				$insert->execute($valores);
				$idinsert=$this->conex->lastInsertId();
				return $idinsert;
			}catch(exception $ex){
				return $ex->getMessage();
			}
		}else{
			echo "else";
			return 0;
		}
	}

	public function execute_update($sql="",$valores=array()){
		if($sql != "" && strlen($sql)>0){
			try{
				$update=$this->conex->prepare($sql);
				$update->execute($valores);
				return $update->rowCount();
				
			}catch(exception $ex){
				return $ex->getMessage();
			}
		}else{
			echo "else";
			return 0;
		}
	}


	public function execute_eliminar($sql="",$valores=array()){
		if($sql != "" && strlen($sql)>0){
			try{
				$elimina=$this->conex->prepare($sql);
				$elimina->execute($valores);
				return "procesado";
			}catch(exception $ex){
				return $ex->getMessage();
			}
		}else{
			echo "else";
			return 0;
		}
	}
}
class PDOECOS{
	private $cadenaconex;
	private $conex;
	private $host = "66.70.255.14";
	private $port = "3306";
	private $user = "apli_edu_ecos";
	private $password = "ZC2KlhsjTqGi";
	private $database = "apli_edu_ecos";
	private $charset ="utf8";

	public function __construct(){
		$conex = $this->connectDB();
		if(!empty($conex)) {
			$this->conex = $conex;			
		}
	}
	function connectDB() {
		try{
			$this->cadenaconex="mysql:host=".$this->host.";port=".$this->port.";dbname=".$this->database.";charset=".$this->charset;
			$options=[
				PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
				PDO::ATTR_EMULATE_PREPARES => false,
			];
			$pdo = new PDO($this->cadenaconex,$this->user,$this->password,$options);
			return $pdo;
		}catch(Exception $ex){
			echo "Error conexions".$ex->getMessage();
			exit;
		}
	}
	

	public function executeconsulta($sql="",$valores=array()){
		if($sql != "" && strlen($sql)>0){
			try{
				$consulta=$this->conex->prepare($sql);
				$consulta->execute($valores);
				if(intval($consulta->errorCode())===0){
					return $consulta->fetchAll(PDO::FETCH_ASSOC);
				}else{
					return intval($consulta->errorCode());
				}
			}catch(exception $ex){
				return $ex->getMessage();
			}
		}else{
			echo "else";
			return 0;
		}
	}

	public function execute_insert($sql="",$valores=array()){
		if($sql != "" && strlen($sql)>0){
			try{
				$insert=$this->conex->prepare($sql);
				$insert->execute($valores);
				$idinsert=$this->conex->lastInsertId();
				return $idinsert;
			}catch(exception $ex){
				return $ex->getMessage();
			}
		}else{
			echo "else";
			return 0;
		}
	}

	public function execute_update($sql="",$valores=array()){
		if($sql != "" && strlen($sql)>0){
			try{
				$update=$this->conex->prepare($sql);
				$update->execute($valores);
				return $update->rowCount();
				
			}catch(exception $ex){
				return $ex->getMessage();
			}
		}else{
			echo "else";
			return 0;
		}
	}


	public function execute_eliminar($sql="",$valores=array()){
		if($sql != "" && strlen($sql)>0){
			try{
				$elimina=$this->conex->prepare($sql);
				$elimina->execute($valores);
				return "procesado";
			}catch(exception $ex){
				return $ex->getMessage();
			}
		}else{
			echo "else";
			return 0;
		}
	}
}


class PDOMAMIOLI{
	private $cadenaconex;
	private $conex;
	private $host = "167.114.163.236";
	private $port = "3306";
	private $user = "ecosspan_moli";
	private $password = "j#iK,8K[FHGx";
	private $database = "ecosspan_mamioli";
	private $charset ="utf8";

	public function __construct(){
		$conex = $this->connectDB();
		if(!empty($conex)) {
			$this->conex = $conex;			
		}
	}
	function connectDB() {
		try{
			$this->cadenaconex="mysql:host=".$this->host.";port=".$this->port.";dbname=".$this->database.";charset=".$this->charset;
			$options=[
				PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
				PDO::ATTR_EMULATE_PREPARES => false,
			];
			$pdo = new PDO($this->cadenaconex,$this->user,$this->password,$options);
			return $pdo;
		}catch(Exception $ex){
			echo "Error conexions".$ex->getMessage();
			exit;
		}
	}
	

	public function executeconsulta($sql="",$valores=array()){
		if($sql != "" && strlen($sql)>0){
			try{
				//echo $sql;
				$consulta=$this->conex->prepare($sql);
				$consulta->execute($valores);
				if(intval($consulta->errorCode())===0){
					return $consulta->fetchAll(PDO::FETCH_ASSOC);
				}else{
					return intval($consulta->errorCode());
				}
			}catch(exception $ex){
				return $ex->getMessage();
			}
		}else{
			echo "else";
			return 0;
		}
	}

	public function execute_insert($sql="",$valores=array()){
		if($sql != "" && strlen($sql)>0){
			try{
				$insert=$this->conex->prepare($sql);
				$insert->execute($valores);
				$idinsert=$this->conex->lastInsertId();
				return $idinsert;
			}catch(exception $ex){
				return $ex->getMessage();
			}
		}else{
			echo "else";
			return 0;
		}
	}

	public function execute_update($sql="",$valores=array()){
		if($sql != "" && strlen($sql)>0){
			try{
				$update=$this->conex->prepare($sql);
				$update->execute($valores);
				return $update->rowCount();
				
			}catch(exception $ex){
				return $ex->getMessage();
			}
		}else{
			echo "else";
			return 0;
		}
	}


	public function execute_eliminar($sql="",$valores=array()){
		if($sql != "" && strlen($sql)>0){
			try{
				$elimina=$this->conex->prepare($sql);
				$elimina->execute($valores);
				return "procesado";
			}catch(exception $ex){
				return $ex->getMessage();
			}
		}else{
			echo "else";
			return 0;
		}
	}
}

class PDOELSY{
	private $cadenaconex;
	private $conex;
	private $host = "66.70.255.14";
	private $port = "3306";
	private $user = "netempire_elsycb";
	private $password = "Tm3Y@1CtWn67";
	private $database = "netempire_elsy2";
	private $charset ="utf8";

	public function __construct(){
		$conex = $this->connectDB();
		if(!empty($conex)) {
			$this->conex = $conex;			
		}
	}
	function connectDB() {
		try{
			$this->cadenaconex="mysql:host=".$this->host.";port=".$this->port.";dbname=".$this->database.";charset=".$this->charset;
			$options=[
				PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
				PDO::ATTR_EMULATE_PREPARES => false,
			];
			$pdo = new PDO($this->cadenaconex,$this->user,$this->password,$options);
			return $pdo;
		}catch(Exception $ex){
			echo "Error conexions".$ex->getMessage();
			exit;
		}
	}
	

	public function executeconsulta($sql="",$valores=array()){
		if($sql != "" && strlen($sql)>0){
			try{
				//echo $sql;
				$consulta=$this->conex->prepare($sql);
				$consulta->execute($valores);
				if(intval($consulta->errorCode())===0){
					return $consulta->fetchAll(PDO::FETCH_ASSOC);
				}else{
					return intval($consulta->errorCode());
				}
			}catch(exception $ex){
				return $ex->getMessage();
			}
		}else{
			echo "else";
			return 0;
		}
	}

	public function execute_insert($sql="",$valores=array()){
		if($sql != "" && strlen($sql)>0){
			try{
				$insert=$this->conex->prepare($sql);
				$insert->execute($valores);
				$idinsert=$this->conex->lastInsertId();
				return $idinsert;
			}catch(exception $ex){
				return $ex->getMessage();
			}
		}else{
			echo "else";
			return 0;
		}
	}

	public function execute_update($sql="",$valores=array()){
		if($sql != "" && strlen($sql)>0){
			try{
				$update=$this->conex->prepare($sql);
				$update->execute($valores);
				return $update->rowCount();
				
			}catch(exception $ex){
				return $ex->getMessage();
			}
		}else{
			echo "else";
			return 0;
		}
	}


	public function execute_eliminar($sql="",$valores=array()){
		if($sql != "" && strlen($sql)>0){
			try{
				$elimina=$this->conex->prepare($sql);
				$elimina->execute($valores);
				return "procesado";
			}catch(exception $ex){
				return $ex->getMessage();
			}
		}else{
			echo "else";
			return 0;
		}
	}
}

class PDORUTASEGURA{
	private $cadenaconex;
	private $conex;
	private $host = "ecos-spanishschool.com";
	private $port = "3306";
	private $user = "ecosspan_rutasg";
	private $password = "_M$,g*E[f}S(";
	private $database = "ecosspan_rutaseg";
	private $charset ="utf8";

	public function __construct(){
		$conex = $this->connectDB();
		if(!empty($conex)) {
			$this->conex = $conex;			
		}
	}
	function connectDB() {
		try{
			$this->cadenaconex="mysql:host=".$this->host.";port=".$this->port.";dbname=".$this->database.";charset=".$this->charset;
			$options=[
				PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
				PDO::ATTR_EMULATE_PREPARES => false,
			];
			$pdo = new PDO($this->cadenaconex,$this->user,$this->password,$options);
			return $pdo;
		}catch(Exception $ex){
			echo "Error conexions".$ex->getMessage();
			exit;
		}
	}
	

	public function executeconsulta($sql="",$valores=array()){
		if($sql != "" && strlen($sql)>0){
			try{
				//echo $sql;
				$consulta=$this->conex->prepare($sql);
				$consulta->execute($valores);
				if(intval($consulta->errorCode())===0){
					return $consulta->fetchAll(PDO::FETCH_ASSOC);
				}else{
					return intval($consulta->errorCode());
				}
			}catch(exception $ex){
				return $ex->getMessage();
			}
		}else{
			echo "else";
			return 0;
		}
	}

	public function execute_insert($sql="",$valores=array()){
		if($sql != "" && strlen($sql)>0){
			try{
				$insert=$this->conex->prepare($sql);
				$insert->execute($valores);
				$idinsert=$this->conex->lastInsertId();
				return $idinsert;
			}catch(exception $ex){
				return $ex->getMessage();
			}
		}else{
			echo "else";
			return 0;
		}
	}

	public function execute_update($sql="",$valores=array()){
		if($sql != "" && strlen($sql)>0){
			try{
				$update=$this->conex->prepare($sql);
				$update->execute($valores);
				return $update->rowCount();
				
			}catch(exception $ex){
				return $ex->getMessage();
			}
		}else{
			echo "else";
			return 0;
		}
	}


	public function execute_eliminar($sql="",$valores=array()){
		if($sql != "" && strlen($sql)>0){
			try{
				$elimina=$this->conex->prepare($sql);
				$elimina->execute($valores);
				return "procesado";
			}catch(exception $ex){
				return $ex->getMessage();
			}
		}else{
			echo "else";
			return 0;
		}
	}
}

class PDODOMOTICACTG{
	private $cadenaconex;
	private $conex;
	private $host = "69.197.152.107";
	private $port = "3306";
	private $user = "usufe";
	private $password = "Naty@2012*";
	private $database = "domotica";
	private $charset ="utf8";

	public function __construct(){
		$conex = $this->connectDB();
		if(!empty($conex)) {
			$this->conex = $conex;			
		}
	}
	function connectDB() {
		try{
			$this->cadenaconex="mysql:host=".$this->host.";port=".$this->port.";dbname=".$this->database.";charset=".$this->charset;
			$options=[
				PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
				PDO::ATTR_EMULATE_PREPARES => false,
			];
			$pdo = new PDO($this->cadenaconex,$this->user,$this->password,$options);
			return $pdo;
		}catch(Exception $ex){
			echo "Error conexions".$ex->getMessage();
			exit;
		}
	}
	

	public function executeconsulta($sql="",$valores=array()){
		if($sql != "" && strlen($sql)>0){
			try{
				//echo $sql;
				$consulta=$this->conex->prepare($sql);
				$consulta->execute($valores);
				if(intval($consulta->errorCode())===0){
					return $consulta->fetchAll(PDO::FETCH_ASSOC);
				}else{
					return intval($consulta->errorCode());
				}
			}catch(exception $ex){
				return $ex->getMessage();
			}
		}else{
			echo "else";
			return 0;
		}
	}

	public function execute_insert($sql="",$valores=array()){
		if($sql != "" && strlen($sql)>0){
			try{
				$insert=$this->conex->prepare($sql);
				$insert->execute($valores);
				$idinsert=$this->conex->lastInsertId();
				return $idinsert;
			}catch(exception $ex){
				return $ex->getMessage();
			}
		}else{
			echo "else";
			return 0;
		}
	}

	public function execute_update($sql="",$valores=array()){
		if($sql != "" && strlen($sql)>0){
			try{
				$update=$this->conex->prepare($sql);
				$update->execute($valores);
				return $update->rowCount();
				
			}catch(exception $ex){
				return $ex->getMessage();
			}
		}else{
			echo "else";
			return 0;
		}
	}


	public function execute_eliminar($sql="",$valores=array()){
		if($sql != "" && strlen($sql)>0){
			try{
				$elimina=$this->conex->prepare($sql);
				$elimina->execute($valores);
				return "procesado";
			}catch(exception $ex){
				return $ex->getMessage();
			}
		}else{
			echo "else";
			return 0;
		}
	}
}

class PDODND{
	private $cadenaconex;
	private $conex;
	private $host = "69.197.152.107";
	private $port = "3306";
	private $user = "usufe";
	private $password = "Naty@2012*";
	private $database = "dnd";
	private $charset ="utf8";

	public function __construct(){
		$conex = $this->connectDB();
		if(!empty($conex)) {
			$this->conex = $conex;			
		}
	}
	function connectDB() {
		try{
			$this->cadenaconex="mysql:host=".$this->host.";port=".$this->port.";dbname=".$this->database.";charset=".$this->charset;
			$options=[
				PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
				PDO::ATTR_EMULATE_PREPARES => false,
			];
			$pdo = new PDO($this->cadenaconex,$this->user,$this->password,$options);
			return $pdo;
		}catch(Exception $ex){
			echo "Error conexions".$ex->getMessage();
			exit;
		}
	}
	

	public function executeconsulta($sql="",$valores=array()){
		if($sql != "" && strlen($sql)>0){
			try{
				//echo $sql;
				$consulta=$this->conex->prepare($sql);
				$consulta->execute($valores);
				if(intval($consulta->errorCode())===0){
					return $consulta->fetchAll(PDO::FETCH_ASSOC);
				}else{
					return intval($consulta->errorCode());
				}
			}catch(exception $ex){
				return $ex->getMessage();
			}
		}else{
			echo "else";
			return 0;
		}
	}

	public function execute_insert($sql="",$valores=array()){
		if($sql != "" && strlen($sql)>0){
			try{
				$insert=$this->conex->prepare($sql);
				$insert->execute($valores);
				$idinsert=$this->conex->lastInsertId();
				return $idinsert;
			}catch(exception $ex){
				return $ex->getMessage();
			}
		}else{
			echo "else";
			return 0;
		}
	}

	public function execute_update($sql="",$valores=array()){
		if($sql != "" && strlen($sql)>0){
			try{
				$update=$this->conex->prepare($sql);
				$update->execute($valores);
				return $update->rowCount();
				
			}catch(exception $ex){
				return $ex->getMessage();
			}
		}else{
			echo "else";
			return 0;
		}
	}


	public function execute_eliminar($sql="",$valores=array()){
		if($sql != "" && strlen($sql)>0){
			try{
				$elimina=$this->conex->prepare($sql);
				$elimina->execute($valores);
				return "procesado";
			}catch(exception $ex){
				return $ex->getMessage();
			}
		}else{
			echo "else";
			return 0;
		}
	}
}

class PDOHALICIA{
	private $cadenaconex;
	private $conex;
	private $host = "66.70.255.14";
	private $port = "3306";
	private $user = "netempir_usuario";
	private $password = "]fQJcs74Lw?D";
	private $database = "netempir_bd";
	private $charset ="utf8";

	public function __construct(){
		$conex = $this->connectDB();
		if(!empty($conex)) {
			$this->conex = $conex;			
		}
	}
	function connectDB() {
		try{
			$this->cadenaconex="mysql:host=".$this->host.";port=".$this->port.";dbname=".$this->database.";charset=".$this->charset;
			$options=[
				PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
				PDO::ATTR_EMULATE_PREPARES => false,
			];
			$pdo = new PDO($this->cadenaconex,$this->user,$this->password,$options);
			return $pdo;
		}catch(Exception $ex){
			echo "Error conexions".$ex->getMessage();
			exit;
		}
	}
	

	public function executeconsulta($sql="",$valores=array()){
		if($sql != "" && strlen($sql)>0){
			try{
				//echo $sql;
				$consulta=$this->conex->prepare($sql);
				$consulta->execute($valores);
				if(intval($consulta->errorCode())===0){
					return $consulta->fetchAll(PDO::FETCH_ASSOC);
				}else{
					return intval($consulta->errorCode());
				}
			}catch(exception $ex){
				return $ex->getMessage();
			}
		}else{
			echo "else";
			return 0;
		}
	}

	public function execute_insert($sql="",$valores=array()){
		if($sql != "" && strlen($sql)>0){
			try{
				$insert=$this->conex->prepare($sql);
				$insert->execute($valores);
				$idinsert=$this->conex->lastInsertId();
				return $idinsert;
			}catch(exception $ex){
				return $ex->getMessage();
			}
		}else{
			echo "else";
			return 0;
		}
	}

	public function execute_update($sql="",$valores=array()){
		if($sql != "" && strlen($sql)>0){
			try{
				$update=$this->conex->prepare($sql);
				$update->execute($valores);
				return $update->rowCount();
				
			}catch(exception $ex){
				return $ex->getMessage();
			}
		}else{
			echo "else";
			return 0;
		}
	}


	public function execute_eliminar($sql="",$valores=array()){
		if($sql != "" && strlen($sql)>0){
			try{
				$elimina=$this->conex->prepare($sql);
				$elimina->execute($valores);
				return "procesado";
			}catch(exception $ex){
				return $ex->getMessage();
			}
		}else{
			echo "else";
			return 0;
		}
	}
}
?>