Ver Mensaje Individual
  #17 (permalink)  
Antiguo 30/09/2011, 01:13
miktrv
 
Fecha de Ingreso: julio-2008
Ubicación: Barcelona
Mensajes: 2.100
Antigüedad: 18 años, 2 meses
Puntos: 165
Respuesta: generador de modelos, controladores y vistas

Libreria:

Código PHP:
<?php

/*

  Description
  @author    _ssx
  @package    Aseguradoras

 */

class Aseguradoras_entity {

    private 
$id_aseguradora;
    public 
$aseguradora;
    public 
$direccion;
    public 
$logo;
    public 
$url_portal;
    public 
$activo;

    
/*
      @package    Aseguradoras

      @access     public
      @return     void
      @param      Integer
     */

    
public function __construct($id_aseguradora = FALSE) {

        if (
$id_aseguradora) {
            
$this->id_aseguradora = $id_aseguradora;
            
$this->load();
        } else {
            
$this->activo = 1;
        }
    }

//----------------------------------------------------------------------------------------------


    /*
      @package    Aseguradoras

      @access     public
      @return     void
      @param      Integer
     */

    
public function set_id_aseguradora($id_aseguradora) {

        
$this->id_aseguradora = $id_aseguradora;
    }

//----------------------------------------------------------------------------------------------


    /*
      @package    Aseguradoras

      @access     public
      @return     Integer
     */

    
public function get_id_aseguradora() {

        return 
$this->id_aseguradora;
    }

//----------------------------------------------------------------------------------------------


    /*
      @package    Aseguradoras

      @access     public
      @return     void
      @param      String
     */

    
public function set_aseguradora($aseguradora) {

        
$this->aseguradora = $aseguradora;
    }

//----------------------------------------------------------------------------------------------


    /*
      @package    Aseguradoras

      @access     public
      @return     String
     */

    
public function get_aseguradora() {

        return 
$this->aseguradora;
    }

//----------------------------------------------------------------------------------------------


    /*
      @package    Aseguradoras

      @access     public
      @return     void
      @param      MEDIUMTEXT
     */

    
public function set_direccion($direccion) {

        
$this->direccion = $direccion;
    }

//----------------------------------------------------------------------------------------------


    /*
      @package    Aseguradoras

      @access     public
      @return     MEDIUMTEXT
     */

    
public function get_direccion() {

        return 
$this->direccion;
    }

//----------------------------------------------------------------------------------------------


    /*
      @package    Aseguradoras

      @access     public
      @return     void
      @param      String
     */

    
public function set_logo($logo) {

        
$this->logo = $logo;
    }

//----------------------------------------------------------------------------------------------


    /*
      @package    Aseguradoras

      @access     public
      @return     String
     */

    
public function get_logo() {

        return 
$this->logo;
    }

//----------------------------------------------------------------------------------------------


    /*
      @package    Aseguradoras

      @access     public
      @return     void
      @param      String
     */

    
public function set_url_portal($url_portal) {

        
$this->url_portal = $url_portal;
    }

//----------------------------------------------------------------------------------------------


    /*
      @package    Aseguradoras

      @access     public
      @return     String
     */

    
public function get_url_portal() {

        return 
$this->url_portal;
    }

//----------------------------------------------------------------------------------------------


    /*
      @package    Aseguradoras

      @access     public
      @return     void
      @param      Boolean
     */

    
public function set_activo($activo = 1) {

        
$this->activo = $activo;
    }

//----------------------------------------------------------------------------------------------


    /*
      @package    Aseguradoras

      @access     public
      @return     Boolean
     */

    
public function get_activo() {

        return 
$this->activo;
    }

//----------------------------------------------------------------------------------------------


    /*
      @package    Aseguradoras

      @access     public
      @return     void
     */

    
public function load() {


        
$sql = '
        
        SELECT
            ' 
. TABLE_ASEGURADORAS_FIELD_ASEGURADORA . ', 
            ' 
. TABLE_ASEGURADORAS_FIELD_DIRECCION . ', 
            ' 
. TABLE_ASEGURADORAS_FIELD_LOGO . ', 
            ' 
. TABLE_ASEGURADORAS_FIELD_URL_PORTAL . ', 
            ' 
. TABLE_ASEGURADORAS_FIELD_ACTIVO . '

        FROM ' 
. TABLE_ASEGURADORAS . '
        WHERE ' 
. TABLE_ASEGURADORAS_FIELD_ID_ASEGURADORA . ' = \'' . $this->id_aseguradora . '\'
   
        '
;
        
$query = mysql_query($sql);
        
$row = mysql_fetch_array($query);
        
$this->aseguradora = $row[TABLE_ASEGURADORAS_FIELD_ASEGURADORA];
        
$this->direccion = $row[TABLE_ASEGURADORAS_FIELD_DIRECCION];
        
$this->logo = $row[TABLE_ASEGURADORAS_FIELD_LOGO];
        
$this->url_portal = $row[TABLE_ASEGURADORAS_FIELD_URL_PORTAL];
        
$this->activo = $row[TABLE_ASEGURADORAS_FIELD_ACTIVO];
    }

//----------------------------------------------------------------------------------------------


    /*
      @package    Aseguradoras

      @access     public
      @return     boolean
     */

    
public function insert() {

        
$out = FALSE;

        
$sql = '

        INSERT INTO ' 
. TABLE_ASEGURADORAS . '
        (
            ' 
. TABLE_ASEGURADORAS_FIELD_ASEGURADORA . ', 
            ' 
. TABLE_ASEGURADORAS_FIELD_DIRECCION . ', 
            ' 
. TABLE_ASEGURADORAS_FIELD_LOGO . ', 
            ' 
. TABLE_ASEGURADORAS_FIELD_URL_PORTAL . ', 
            ' 
. TABLE_ASEGURADORAS_FIELD_ACTIVO . '

        )
        VALUES
        (
            \'' 
. $this->aseguradora . '\', 
            \'' 
. $this->direccion . '\', 
            \'' 
. $this->logo . '\', 
            \'' 
. $this->url_portal . '\', 
            \'' 
. $this->activo . '\'

        )
        ;
        '
;

        if (
mysql_query($sql) and mysql_affected_rows() == 1) {
            
$out = TRUE;
        }
        
$this->id_aseguradora = mysql_insert_id();

        return 
$out;
    }

//----------------------------------------------------------------------------------------------


    /*
      @package    Aseguradoras

      @access     public
      @return     boolean
     */

    
public function update() {

        
$out = FALSE;

        
$sql = '
        UPDATE ' 
. TABLE_ASEGURADORAS . ' SET  
            ' 
. TABLE_ASEGURADORAS_FIELD_ASEGURADORA . ' = \'' . $this->aseguradora . '\', 
            ' 
. TABLE_ASEGURADORAS_FIELD_DIRECCION . ' = \'' . $this->direccion . '\', 
            ' 
. TABLE_ASEGURADORAS_FIELD_LOGO . ' = \'' . $this->logo . '\', 
            ' 
. TABLE_ASEGURADORAS_FIELD_URL_PORTAL . ' = \'' . $this->url_portal . '\', 
            ' 
. TABLE_ASEGURADORAS_FIELD_ACTIVO . ' = \'' . $this->activo . '\'
         WHERE ' 
. TABLE_ASEGURADORAS_FIELD_ID_ASEGURADORA . ' = \'' . $this->id_aseguradora . '\'
        '
;


        if (
mysql_query($sql) and mysql_affected_rows() == 1) {
            
$out = TRUE;
        }

        return 
$out;
    }

//----------------------------------------------------------------------------------------------


    /*
      Save the data in database, check if register exists for create or update

      @package    Aseguradoras

      @access     public
      @return     boolean
     */

    /*
      public function save() {

      if($this->get_id_aseguradora()) {
      return $this->update();
      } else {
      return $this->insert();
      }

      }
     */

//----------------------------------------------------------------------------------------------


    /*
      Save data when object deleted in memory! :D

      @package    Aseguradoras

      @access     public
      @return     void
     */

    /*
      public function __destruct() {

      $this->save();

      }
     */

//----------------------------------------------------------------------------------------------
}
__________________
Gracias por el Karma :D

empleo ofertas de trabajo