Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class Conexion{
- protected $conexion_db;
- public function Conectar()
- {
- try{
- $this->conexion_db= new PDO('mysql:host=localhost; dbname=bd_espamep','root','123456');
- $this->conexion_db-> setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
- $this->conexion_db->exec("SET CHARACTER SET utf8"):
- return $this->conexion_db;
- }
- catch(PDOException $e){
- echo "La linea de error es: " . $e->getline();
- }
- }
- public function desconectar()
- {
- $this -> conexion = null;
- }
- }
- ?>
- Negocios
- <?php
- require_once "../Conexion/CapaDatos.php";
- class Unidad extends Conexion
- {
- public function CapaNegocios()
- {
- parent::__construct();
- }
- public function InsertarUnidad($idempresa, $uni_nombre, $uni_objetivo, $uni_logo, $uni_eliminado)
- {
- try
- {
- $sql = "INSERT INTO unidad(idempresa, uni_nombre, uni_objetivo, uni_logo, uni_eliminado) VALUES (?,?,?,?,?)";
- $sentencia = $this->conexion_db->prepare($sql);
- $sentencia -> bind_param('isssi',$uni_nombre,$uni_objetivo, $uni_logo);
- $sentencia->execute();
- echo "Guardado";
- }catch(Exception $e){
- echo $e->getMessage();
- }
- }
- }
- ?>
- <?php
- require_once "../negocios/CapaNegocios.php";
- try{
- if(!empty($_POST))
- {
- $idempresa = 1;
- $uni_eliminado = 1;
- $uni_nombre = $_POST['txtunidad'];
- $uni_objetivo = $_POST['txtobjetivou'];
- $uni_logo = $_POST['logou'];
- $objetoNegocio= new Unidad();
- if(isset($_POST["Guardar"]))
- {
- $objetoNegocio-> InsertarUnidad($idempresa, $uni_nombre, $uni_objetivo, $uni_logo, $uni_eliminado);
- }
- }
- }
- catch(PD0Eception $e)
- {
- echo $e -> getMessage();
- }
- ?>
Add Comment
Please, Sign In to add comment