Ver Mensaje Individual
  #28 (permalink)  
Antiguo 05/10/2011, 01:01
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

Coloco el código generado:

Library:

Código PHP:
<?php

/*

    Description
    @author            miktrv
    @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      
    */

    
public function __construct($id_aseguradora = FALSE) {
    
        if(
$id_aseguradora) {
            
$this->id_aseguradora = $id_aseguradora;
            
$this->load_by_id_aseguradora();
        } else {
            
//set default values
            
$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) {
    
    if(
$activo) {
        
$activo = 1;
    } else {
        
$activo = 0;
    }
    
        
$this->activo = $activo;
    
    }

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


    /*
        @package    Aseguradoras

        @access     public
        @return     Boolean
    */

    
public function get_activo() {
    
        return 
$this->activo;
    
    }

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


    /*
        @package    Aseguradoras

        @access     public
        @return     Aseguradoras
    */

    
public function load_by_id_aseguradora() {
    

        if(
$this->id_aseguradora) {

    
            
$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->set_aseguradora($row[TABLE_ASEGURADORAS_FIELD_ASEGURADORA]);
            
$this->set_direccion($row[TABLE_ASEGURADORAS_FIELD_DIRECCION]);
            
$this->set_logo($row[TABLE_ASEGURADORAS_FIELD_LOGO]);
            
$this->set_url_portal($row[TABLE_ASEGURADORAS_FIELD_URL_PORTAL]);
            
$this->set_activo($row[TABLE_ASEGURADORAS_FIELD_ACTIVO]);

        }

    }

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


    /*
        @package    Aseguradoras

        @access     public
        @return     integer
    */

    
public function update_by_id_aseguradora() {
    
        
$out = 0;
    
        if(
$this->id_aseguradora) {

    
            
$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 . '\'

            '
;
    
            
$query = mysql_query($sql);
            
$out = mysql_affected_rows();

        }

        return 
$out;

    }

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


    /*
        @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;
    
    }

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


    /*
        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