Tema: mvc php
Ver Mensaje Individual
  #5 (permalink)  
Antiguo 19/07/2013, 07:58
Avatar de oscard41
oscard41
 
Fecha de Ingreso: mayo-2012
Ubicación: Caracas
Mensajes: 288
Antigüedad: 12 años
Puntos: 8
Respuesta: mvc php

Cita:
Iniciado por miguec04 Ver Mensaje
ayudaría mucho si dejas ver como hiciste la clase conexión y como la estas llamando
ok Bueno aqui te dejo la clase de conexion que hice....

Código PHP:
Ver original
  1. class conexion{
  2.  
  3.     private $server;
  4.     Private $user;
  5.     private $clave;
  6.     private $DB;
  7.    
  8.     public function __construct(){
  9.        
  10.         $this->conexionDB();
  11.     }
  12.  
  13.  public function conexionDB(){
  14.        
  15.        $this->server= $this->leerIni("Config","MYSQL","Server");
  16.        $this->user= $this->leerIni("Config","MYSQL","User");
  17.        $this->clave= $this->leerIni("Config","MYSQL","Clave");
  18.        $conexion= mysql_connect($this->server,$this->user,$this->clave);
  19.        if($conexion){
  20.          $this->DB= $this->leerIni("Config","MYSQL","DB");
  21.          mysql_select_db($this->DB);
  22.        }else{
  23.          return "Error";
  24.        }
  25.     }
  26.    
  27.     public function leerIni($Archivo, $Sector, $Dato){
  28.         $Archivo= $Archivo.'.ini';
  29.         $is=parse_ini_file($Archivo,true);
  30.         if(is_array($is) && file_exists($Archivo)){
  31.             return $is[$Sector][$Dato];
  32.         }else{
  33.             return "Error";
  34.         }
  35.     }
  36.    
  37.     public function closeDB(){
  38.         mysql_close();
  39.     }
  40. }

Los datos de la conexion los tengo en un archivo .ini por eso la funcion leerini...

Última edición por oscard41; 19/07/2013 a las 08:19