<?php

class mysqlresponsable {
  private $usuario;
  private $servidor;
  private $password;
  private $base_datos;
  private $conexion;
  private $result;
  var $flag = false;
  static $_instance;
  function __construct(){
    require_once ("configdatos.php");
    $this->usuario= USER;
    $this->password= PASS;
    $this->servidor= HOST;
    $this->base_datos= DB;
    $this->conectar();
  }


public function setresponsable($responsable){
$querypregunta ="INSERT INTO tblresponsables(RESPONSABLE) VALUES ('$responsable')";
    if(mysql_query($querypregunta)){
      return "1";
    }else{
      return mysql_error();
    }

}

  public function getresponsable(){
    $querypreguntas = $this->read("SELECT ID_RESPONSABLE,RESPONSABLE FROM tblresponsables");
    return $querypreguntas;
  }



  //UPDATES

public function updateresponsable($id_responsable,$responsable){
     $updaterespuesta = "UPDATE tblresponsables SET RESPONSABLE = '$responsable' 
                            WHERE ID_RESPONSABLE = '$id_responsable'";
     if(mysql_query($updaterespuesta)){
        return "1";
     }else{
      return mysql_errno();

     }
}






 private function read($sql){
  $resultado = mysql_query($sql); 
   if(mysql_num_rows($resultado)> 0){
     while($fila = mysql_fetch_array($resultado)){
         $arreglo[] =$fila;
       }
         return $arreglo;
   }else{
     return "0";
   }
  }

  private function conectar(){
  $this->conexion = mysql_connect($this->servidor,$this->usuario,$this->password);
  mysql_select_db($this->base_datos,$this->conexion);
  @mysql_query("SET NAMES 'utf8'");
 }


}
?>