Campo de outra classe em um Grid Galera ainda não consegui desenrolar, já tentaram me ajudar, mas sem sucesso ainda. Meu problema é o seguinte, quero passar para o grid um informação de outra classe relacionada, as classes são as seguintes: Titular (Mestre) ...
MO
Campo de outra classe em um Grid  
Fechado
Galera ainda não consegui desenrolar, já tentaram me ajudar, mas sem sucesso ainda.
Meu problema é o seguinte, quero passar para o grid um informação de outra classe relacionada,
as classes são as seguintes:

Titular (Mestre)

  1. <?php
  2. /**
  3.  * Titular Active Record
  4.  * @author  <your-name-here>
  5.  */
  6. class Titular extends TRecord
  7. {
  8.     const TABLENAME 'titular';
  9.     const PRIMARYKEY'id';
  10.     const IDPOLICY =  'serial'// {max, serial}
  11.     
  12.     
  13.     private $tipo_nec_esp;
  14.     private $ocupacaoprof;
  15.     private $escolaridade;
  16.     private $sithabitacional;
  17.     private $estado_civil;
  18.     private $sitconjugal;
  19.     private $situacao_trab;
  20.     private $beneficio;
  21.     private $tempo_trabalho;
  22.     private $renda_mensal;
  23.     private $renda_comp;
  24.     private $compfams;
  25.     /**
  26.      * Constructor method
  27.      */
  28.     public function __construct(2599 NULL$callObjectLoad TRUE)
  29.     {
  30.         parent::__construct(2599$callObjectLoad);
  31.         parent::addAttribute('nome');
  32.         parent::addAttribute('apelido');
  33.         parent::addAttribute('cpf');
  34.         parent::addAttribute('nis');
  35.         parent::addAttribute('celular1');
  36.         parent::addAttribute('celular2');
  37.         parent::addAttribute('telefone');
  38.         parent::addAttribute('contato');
  39.         parent::addAttribute('sexo');
  40.         parent::addAttribute('pai');
  41.         parent::addAttribute('mae');
  42.         parent::addAttribute('rg');
  43.         parent::addAttribute('viarg');
  44.         parent::addAttribute('datemisrg');
  45.         parent::addAttribute('ufrg');
  46.         parent::addAttribute('orgexprg');
  47.         parent::addAttribute('datnasc');
  48.         parent::addAttribute('naturalidade');
  49.         parent::addAttribute('endereco');
  50.         parent::addAttribute('numero');
  51.         parent::addAttribute('complemento');
  52.         parent::addAttribute('pontoref');
  53.         parent::addAttribute('cep');
  54.         parent::addAttribute('localtrabalho');
  55.         parent::addAttribute('portnecesp');
  56.         parent::addAttribute('qualnecespecial');
  57.         parent::addAttribute('necadap');
  58.         parent::addAttribute('qtdpesres');
  59.         parent::addAttribute('valorbeneficio');
  60.         parent::addAttribute('desistente');
  61.         parent::addAttribute('declaracao');
  62.         parent::addAttribute('situacaoderua');
  63.         parent::addAttribute('assocmorador');
  64.         parent::addAttribute('participa');
  65.         parent::addAttribute('situacao_trab_id');
  66.         parent::addAttribute('escolaridade_id');
  67.         parent::addAttribute('ocupacaoprof_id');
  68.         parent::addAttribute('tipo_nec_esp_id');
  69.         parent::addAttribute('tempo_trabalho_id');
  70.         parent::addAttribute('renda_mensal_id');
  71.         parent::addAttribute('estado_civil_id');
  72.         parent::addAttribute('beneficio_id');
  73.         parent::addAttribute('sithabitacional_id');
  74.         parent::addAttribute('sitconjugal_id');
  75.         parent::addAttribute('bairro_id');
  76.         parent::addAttribute('logradouro_id');
  77.         parent::addAttribute('rendatotal');
  78.         parent::addAttribute('renda_comp_id');
  79.         parent::addAttribute('observacao');
  80.     }
  81.     
  82.     /**
  83.      * Method set_tipo_nec_esp
  84.      * Sample of usage: $titular->tipo_nec_esp = $object;
  85.      * @param $object Instance of TipoNecEsp
  86.      */
  87.     public function set_tipo_nec_esp(TipoNecEsp $object)
  88.     {
  89.         $this->tipo_nec_esp $object;
  90.         $this->tipo_nec_esp_id $object->id;
  91.     }
  92.     
  93.     /**
  94.      * Method get_tipo_nec_esp
  95.      * Sample of usage: $titular->tipo_nec_esp->attribute;
  96.      * @returns TipoNecEsp instance
  97.      */
  98.     public function get_tipo_nec_esp()
  99.     {
  100.         // loads the associated object
  101.         if (empty($this->tipo_nec_esp))
  102.             $this->tipo_nec_esp = new TipoNecEsp($this->tipo_nec_esp_id);
  103.     
  104.         // returns the associated object
  105.         return $this->tipo_nec_esp;
  106.     }
  107.     
  108.     
  109.     /**
  110.      * Method set_ocupacaoprof
  111.      * Sample of usage: $titular->ocupacaoprof = $object;
  112.      * @param $object Instance of Ocupacaoprof
  113.      */
  114.     public function set_ocupacaoprof(Ocupacaoprof $object)
  115.     {
  116.         $this->ocupacaoprof $object;
  117.         $this->ocupacaoprof_id $object->id;
  118.     }
  119.     
  120.     /**
  121.      * Method get_ocupacaoprof
  122.      * Sample of usage: $titular->ocupacaoprof->attribute;
  123.      * @returns Ocupacaoprof instance
  124.      */
  125.     public function get_ocupacaoprof()
  126.     {
  127.         // loads the associated object
  128.         if (empty($this->ocupacaoprof))
  129.             $this->ocupacaoprof = new Ocupacaoprof($this->ocupacaoprof_id);
  130.     
  131.         // returns the associated object
  132.         return $this->ocupacaoprof;
  133.     }
  134.     
  135.     
  136.     /**
  137.      * Method set_escolaridade
  138.      * Sample of usage: $titular->escolaridade = $object;
  139.      * @param $object Instance of Escolaridade
  140.      */
  141.     public function set_escolaridade(Escolaridade $object)
  142.     {
  143.         $this->escolaridade $object;
  144.         $this->escolaridade_id $object->id;
  145.     }
  146.     
  147.     /**
  148.      * Method get_escolaridade
  149.      * Sample of usage: $titular->escolaridade->attribute;
  150.      * @returns Escolaridade instance
  151.      */
  152.     public function get_escolaridade()
  153.     {
  154.         // loads the associated object
  155.         if (empty($this->escolaridade))
  156.             $this->escolaridade = new Escolaridade($this->escolaridade_id);
  157.     
  158.         // returns the associated object
  159.         return $this->escolaridade;
  160.     }
  161.     
  162.     /**
  163.      * Method set_sithabitacional
  164.      * Sample of usage: $titular->sithabitacional = $object;
  165.      * @param $object Instance of Sithabitacional
  166.      */
  167.     public function set_sithabitacional(Sithabitacional $object)
  168.     {
  169.         $this->sithabitacional $object;
  170.         $this->sithabitacional_id $object->id;
  171.     }
  172.     
  173.     /**
  174.      * Method get_sithabitacional
  175.      * Sample of usage: $titular->sithabitacional->attribute;
  176.      * @returns Sithabitacional instance
  177.      */
  178.     public function get_sithabitacional()
  179.     {
  180.         // loads the associated object
  181.         if (empty($this->sithabitacional))
  182.             $this->sithabitacional = new Sithabitacional($this->sithabitacional_id);
  183.     
  184.         // returns the associated object
  185.         return $this->sithabitacional;
  186.     }
  187.     
  188.     
  189.     /**
  190.      * Method set_estado_civil
  191.      * Sample of usage: $titular->estado_civil = $object;
  192.      * @param $object Instance of EstadoCivil
  193.      */
  194.     public function set_estado_civil(EstadoCivil $object)
  195.     {
  196.         $this->estado_civil $object;
  197.         $this->estado_civil_id $object->id;
  198.     }
  199.     
  200.     /**
  201.      * Method get_estado_civil
  202.      * Sample of usage: $titular->estado_civil->attribute;
  203.      * @returns EstadoCivil instance
  204.      */
  205.     public function get_estado_civil()
  206.     {
  207.         // loads the associated object
  208.         if (empty($this->estado_civil))
  209.             $this->estado_civil = new EstadoCivil($this->estado_civil_id);
  210.     
  211.         // returns the associated object
  212.         return $this->estado_civil;
  213.     }
  214.     
  215.     
  216.      /**
  217.      * Method set_sitconjugal
  218.      * Sample of usage: $titular->sitconjugal = $object;
  219.      * @param $object Instance of Sitconjugal
  220.      */
  221.     public function set_sitconjugal(Sitconjugal $object)
  222.     {
  223.         $this->sitconjugal $object;
  224.         $this->sitconjugal_id $object->id;
  225.     }
  226.     
  227.     /**
  228.      * Method get_sitconjugal
  229.      * Sample of usage: $titular->sitconjugal->attribute;
  230.      * @returns Sitconjugal instance
  231.      */
  232.     public function get_sitconjugal()
  233.     {
  234.         // loads the associated object
  235.         if (empty($this->sitconjugal))
  236.             $this->sitconjugal = new Sitconjugal($this->sitconjugal_id);
  237.     
  238.         // returns the associated object
  239.         return $this->sitconjugal;
  240.     }
  241.    
  242.     /**
  243.      * Method set_situacao_trab
  244.      * Sample of usage: $titular->situacao_trab = $object;
  245.      * @param $object Instance of SituacaoTrab
  246.      */
  247.     public function set_situacao_trab(SituacaoTrab $object)
  248.     {
  249.         $this->situacao_trab $object;
  250.         $this->situacao_trab_id $object->id;
  251.     }
  252.     
  253.     /**
  254.      * Method get_situacao_trab
  255.      * Sample of usage: $titular->situacao_trab->attribute;
  256.      * @returns SituacaoTrab instance
  257.      */
  258.     public function get_situacao_trab()
  259.     {
  260.         // loads the associated object
  261.         if (empty($this->situacao_trab))
  262.             $this->situacao_trab = new SituacaoTrab($this->situacao_trab_id);
  263.     
  264.         // returns the associated object
  265.         return $this->situacao_trab;
  266.     }
  267.     
  268.     
  269.     /**
  270.      * Method set_beneficio
  271.      * Sample of usage: $titular->beneficio = $object;
  272.      * @param $object Instance of Beneficio
  273.      */
  274.     public function set_beneficio(Beneficio $object)
  275.     {
  276.         $this->beneficio $object;
  277.         $this->beneficio_id $object->id;
  278.     }
  279.     
  280.     /**
  281.      * Method get_beneficio
  282.      * Sample of usage: $titular->beneficio->attribute;
  283.      * @returns Beneficio instance
  284.      */
  285.     public function get_beneficio()
  286.     {
  287.         // loads the associated object
  288.         if (empty($this->beneficio))
  289.             $this->beneficio = new Beneficio($this->beneficio_id);
  290.     
  291.         // returns the associated object
  292.         return $this->beneficio;
  293.     }
  294.     
  295.     
  296.     /**
  297.      * Method set_tempo_trabalho
  298.      * Sample of usage: $titular->tempo_trabalho = $object;
  299.      * @param $object Instance of TempoTrabalho
  300.      */
  301.     public function set_tempo_trabalho(TempoTrabalho $object)
  302.     {
  303.         $this->tempo_trabalho $object;
  304.         $this->tempo_trabalho_id $object->id;
  305.     }
  306.     
  307.     /**
  308.      * Method get_tempo_trabalho
  309.      * Sample of usage: $titular->tempo_trabalho->attribute;
  310.      * @returns TempoTrabalho instance
  311.      */
  312.     public function get_tempo_trabalho()
  313.     {
  314.         // loads the associated object
  315.         if (empty($this->tempo_trabalho))
  316.             $this->tempo_trabalho = new TempoTrabalho($this->tempo_trabalho_id);
  317.     
  318.         // returns the associated object
  319.         return $this->tempo_trabalho;
  320.     }
  321.     
  322.     
  323.     /**
  324.      * Method set_renda_mensal
  325.      * Sample of usage: $titular->renda_mensal = $object;
  326.      * @param $object Instance of RendaMensal
  327.      */
  328.     public function set_renda_mensal(RendaMensal $object)
  329.     {
  330.         $this->renda_mensal $object;
  331.         $this->renda_mensal_id $object->id;
  332.     }
  333.     
  334.     /**
  335.      * Method get_renda_mensal
  336.      * Sample of usage: $titular->renda_mensal->attribute;
  337.      * @returns RendaMensal instance
  338.      */
  339.     public function get_renda_mensal()
  340.     {
  341.         // loads the associated object
  342.         if (empty($this->renda_mensal))
  343.             $this->renda_mensal = new RendaMensal($this->renda_mensal_id);
  344.     
  345.         // returns the associated object
  346.         return $this->renda_mensal;
  347.     }
  348.     
  349.     /**
  350.      * Method set_renda_comp
  351.      * Sample of usage: $titular->renda_mensal = $object;
  352.      * @param $object Instance of RendaMensal
  353.      */
  354.     public function set_renda_comp(RendaCompl $object)
  355.     {
  356.         $this->renda_comp $object;
  357.         $this->renda_comp_id $object->id;
  358.     }
  359.     
  360.     /**
  361.      * Method get_renda_comp
  362.      * Sample of usage: $titular->renda_mensal->attribute;
  363.      * @returns RendaMensal instance
  364.      */
  365.     public function get_renda_comp()
  366.     {
  367.         // loads the associated object
  368.         if (empty($this->renda_comp))
  369.             $this->renda_comp = new RendaCompl($this->renda_comp_id);
  370.     
  371.         // returns the associated object
  372.         return $this->renda_comp;
  373.     }
  374.     public function addCompfam(CompFam $object)
  375.     {
  376.         $this->compfams[] = $object;
  377.     }        
  378.     
  379.     public function getCompfams()
  380.     {
  381.         return $this->compfams;
  382.     }
  383.     
  384.     public function load(2599)
  385.     {
  386.         $repository = new TRepository('CompFam');
  387.         $criteria   = new TCriteria;
  388.         $criteria->add(new TFilter('compf_titular_id','=',2599));
  389.         $this->compfams $repository->load($criteria);
  390.         return parent::load(2599);        
  391.     }
  392.     
  393.     public function store()
  394.     {
  395.         parent::store();
  396.         $repository = new TRepository('CompFam');
  397.         $criteria   = new TCriteria;
  398.         $criteria->add(new TFilter('compf_titular_id','=',$this->id));
  399.         $criteria->delete($criteria);
  400.         
  401.         if ($htis->compfams)
  402.         {
  403.             foreach($this->compfams as $compfam)
  404.             {
  405.                 unset($compfam->id);
  406.                 $compfam->compf_titular_id $this->id;
  407.                 $compfam->store();
  408.             }
  409.         }    
  410.     }
  411.     
  412.     public function delete(2599 NULL)
  413.     {
  414.         2599 = isset(2599) ? 2599 $this->id;
  415.         $repository = new TRepository('CompFam');
  416.         $criteria   = new TCriteria;
  417.         $criteria->add(new TFilter('compf_titular_id','=',2599));
  418.         $criteria->delete($criteria);
  419.         
  420.         
  421.         parent::delete(2599);         
  422.     }    
  423.     
  424. }

Pacotão Dominando o Adianti Framework 7
O material mais completo de treinamento do Framework.
Curso em vídeo aulas + Livro completo + Códigos fontes do projeto ERPHouse.
Conteúdo Atualizado! Versão 7.4


Dominando o Adianti 7 Quero me inscrever agora!

Comentários (5)


MO

Classe CompFam (Detalhe) "Composição Familiar"


  1. <?php
  2. /**
  3.  * CompFam Active Record
  4.  * @author  <your-name-here>
  5.  */
  6. class CompFam extends TRecord
  7. {
  8.     const TABLENAME 'comp_fam';
  9.     const PRIMARYKEY'id';
  10.     const IDPOLICY =  'serial'// {max, serial}
  11.     
  12.     
  13.     private $tipo_nec_esp;
  14.     private $ocupacaoprof;
  15.     private $escolaridade;
  16.     private $estado_civil;
  17.     private $sitconjugal;
  18.     private $situacao_trab;
  19.     private $beneficio;
  20.     private $tempo_trabalho;
  21.     private $grauparent;
  22.     private $renda_mensal;
  23.     private $renda_compl;
  24.     /**
  25.      * Constructor method
  26.      */
  27.     public function __construct($id NULL$callObjectLoad TRUE)
  28.     {
  29.         parent::__construct($id$callObjectLoad);
  30.         parent::addAttribute('compf_nome');
  31.         parent::addAttribute('compf_Idade');
  32.         parent::addAttribute('compf_renda');
  33.         parent::addAttribute('compf_valbenef');
  34.         parent::addAttribute('compf_localtrabalho');
  35.         parent::addAttribute('compf_titular_id');
  36.         parent::addAttribute('compf_renda_comp_id');
  37.         parent::addAttribute('compf_situacaotrab_id');
  38.         parent::addAttribute('compf_escolaridade_id');
  39.         parent::addAttribute('compf_ocupacaoprof_id');
  40.         parent::addAttribute('compf_tipo_nec_esp_id');
  41.         parent::addAttribute('compf_tempo_trabalho_id');
  42.         parent::addAttribute('compf_renda_mensal_id');
  43.         parent::addAttribute('compf_grauparent_id');
  44.         parent::addAttribute('compf_estado_civil_id');
  45.         parent::addAttribute('compf_sitconjugal_id');
  46.         parent::addAttribute('compf_qualnecespecial');
  47.     }
  48.     
  49.     /**
  50.      * Method set_tipo_nec_esp
  51.      * Sample of usage: $comp_fam->tipo_nec_esp = $object;
  52.      * @param $object Instance of TipoNecEsp
  53.      */
  54.     public function set_tipo_nec_esp(TipoNecEsp $object)
  55.     {
  56.         $this->tipo_nec_esp $object;
  57.         $this->tipo_nec_esp_id $object->id;
  58.     }
  59.     
  60.     /**
  61.      * Method get_tipo_nec_esp
  62.      * Sample of usage: $comp_fam->tipo_nec_esp->attribute;
  63.      * @returns TipoNecEsp instance
  64.      */
  65.     public function get_tipo_nec_esp()
  66.     {
  67.         // loads the associated object
  68.         if (empty($this->tipo_nec_esp))
  69.             $this->tipo_nec_esp = new TipoNecEsp($this->tipo_nec_esp_id);
  70.     
  71.         // returns the associated object
  72.         return $this->tipo_nec_esp;
  73.     }
  74.     
  75.     
  76.     /**
  77.      * Method set_ocupacaoprof
  78.      * Sample of usage: $comp_fam->ocupacaoprof = $object;
  79.      * @param $object Instance of Ocupacaoprof
  80.      */
  81.     public function set_ocupacaoprof(Ocupacaoprof $object)
  82.     {
  83.         $this->ocupacaoprof $object;
  84.         $this->ocupacaoprof_id $object->id;
  85.     }
  86.     
  87.     /**
  88.      * Method get_ocupacaoprof
  89.      * Sample of usage: $comp_fam->ocupacaoprof->attribute;
  90.      * @returns Ocupacaoprof instance
  91.      */
  92.     public function get_ocupacaoprof()
  93.     {
  94.         // loads the associated object
  95.         if (empty($this->ocupacaoprof))
  96.             $this->ocupacaoprof = new Ocupacaoprof($this->ocupacaoprof_id);
  97.     
  98.         // returns the associated object
  99.         return $this->ocupacaoprof;
  100.     }
  101.     
  102.     
  103.     /**
  104.      * Method set_escolaridade
  105.      * Sample of usage: $comp_fam->escolaridade = $object;
  106.      * @param $object Instance of Escolaridade
  107.      */
  108.     public function set_escolaridade(Escolaridade $object)
  109.     {
  110.         $this->escolaridade $object;
  111.         $this->escolaridade_id $object->id;
  112.     }
  113.     
  114.     /**
  115.      * Method get_escolaridade
  116.      * Sample of usage: $comp_fam->escolaridade->attribute;
  117.      * @returns Escolaridade instance
  118.      */
  119.     public function get_escolaridade()
  120.     {
  121.         // loads the associated object
  122.         if (empty($this->escolaridade))
  123.             $this->escolaridade = new Escolaridade($this->escolaridade_id);
  124.     
  125.         // returns the associated object
  126.         return $this->escolaridade;
  127.     }
  128.     
  129.     
  130.     /**
  131.      * Method set_estado_civil
  132.      * Sample of usage: $comp_fam->estado_civil = $object;
  133.      * @param $object Instance of EstadoCivil
  134.      */
  135.     public function set_estado_civil(EstadoCivil $object)
  136.     {
  137.         $this->estado_civil $object;
  138.         $this->estado_civil_id $object->id;
  139.     }
  140.     
  141.     /**
  142.      * Method get_estado_civil
  143.      * Sample of usage: $comp_fam->estado_civil->attribute;
  144.      * @returns EstadoCivil instance
  145.      */
  146.     public function get_estado_civil()
  147.     {
  148.         // loads the associated object
  149.         if (empty($this->estado_civil))
  150.             $this->estado_civil = new EstadoCivil($this->estado_civil_id);
  151.     
  152.         // returns the associated object
  153.         return $this->estado_civil;
  154.     }
  155.     
  156.     
  157.     /**
  158.      * Method set_sitconjugal
  159.      * Sample of usage: $comp_fam->sitconjugal = $object;
  160.      * @param $object Instance of Sitconjugal
  161.      */
  162.     public function set_sitconjugal(Sitconjugal $object)
  163.     {
  164.         $this->sitconjugal $object;
  165.         $this->sitconjugal_id $object->id;
  166.     }
  167.     
  168.     /**
  169.      * Method get_sitconjugal
  170.      * Sample of usage: $comp_fam->sitconjugal->attribute;
  171.      * @returns Sitconjugal instance
  172.      */
  173.     public function get_sitconjugal()
  174.     {
  175.         // loads the associated object
  176.         if (empty($this->sitconjugal))
  177.             $this->sitconjugal = new Sitconjugal($this->sitconjugal_id);
  178.     
  179.         // returns the associated object
  180.         return $this->sitconjugal;
  181.     }
  182.     
  183.     
  184.     /**
  185.      * Method set_situacao_trab
  186.      * Sample of usage: $comp_fam->situacao_trab = $object;
  187.      * @param $object Instance of SituacaoTrab
  188.      */
  189.     public function set_situacao_trab(SituacaoTrab $object)
  190.     {
  191.         $this->situacao_trab $object;
  192.         $this->situacao_trab_id $object->id;
  193.     }
  194.     
  195.     /**
  196.      * Method get_situacao_trab
  197.      * Sample of usage: $comp_fam->situacao_trab->attribute;
  198.      * @returns SituacaoTrab instance
  199.      */
  200.     public function get_situacao_trab()
  201.     {
  202.         // loads the associated object
  203.         if (empty($this->situacao_trab))
  204.             $this->situacao_trab = new SituacaoTrab($this->situacao_trab_id);
  205.     
  206.         // returns the associated object
  207.         return $this->situacao_trab;
  208.     }
  209.     
  210.     
  211.     /**
  212.      * Method set_beneficio
  213.      * Sample of usage: $comp_fam->beneficio = $object;
  214.      * @param $object Instance of Beneficio
  215.      */
  216.     public function set_beneficio(Beneficio $object)
  217.     {
  218.         $this->beneficio $object;
  219.         $this->beneficio_id $object->id;
  220.     }
  221.     
  222.     /**
  223.      * Method get_beneficio
  224.      * Sample of usage: $comp_fam->beneficio->attribute;
  225.      * @returns Beneficio instance
  226.      */
  227.     public function get_beneficio()
  228.     {
  229.         // loads the associated object
  230.         if (empty($this->beneficio))
  231.             $this->beneficio = new Beneficio($this->beneficio_id);
  232.     
  233.         // returns the associated object
  234.         return $this->beneficio;
  235.     }
  236.     
  237.     
  238.     /**
  239.      * Method set_tempo_trabalho
  240.      * Sample of usage: $comp_fam->tempo_trabalho = $object;
  241.      * @param $object Instance of TempoTrabalho
  242.      */
  243.     public function set_tempo_trabalho(TempoTrabalho $object)
  244.     {
  245.         $this->tempo_trabalho $object;
  246.         $this->tempo_trabalho_id $object->id;
  247.     }
  248.     
  249.     /**
  250.      * Method get_tempo_trabalho
  251.      * Sample of usage: $comp_fam->tempo_trabalho->attribute;
  252.      * @returns TempoTrabalho instance
  253.      */
  254.     public function get_tempo_trabalho()
  255.     {
  256.         // loads the associated object
  257.         if (empty($this->tempo_trabalho))
  258.             $this->tempo_trabalho = new TempoTrabalho($this->tempo_trabalho_id);
  259.     
  260.         // returns the associated object
  261.         return $this->tempo_trabalho;
  262.     }
  263.     
  264.     
  265.     /**
  266.      * Method set_grauparent
  267.      * Sample of usage: $comp_fam->grauparent = $object;
  268.      * @param $object Instance of Grauparent
  269.      */
  270.     public function set_grauparent(Grauparent $object)
  271.     {
  272.         $this->grauparent $object;
  273.         $this->grauparent_id $object->id;
  274.     }
  275.     
  276.     /**
  277.      * Method get_grauparent
  278.      * Sample of usage: $comp_fam->grauparent->attribute;
  279.      * @returns Grauparent instance
  280.      */
  281.     public function get_grauparent()
  282.     {
  283.         // loads the associated object
  284.         if (empty($this->grauparent))
  285.            $this->grauparent = new Grauparent($this->grauparent_id);
  286.     
  287.         // returns the associated object
  288.         return $this->grauparent;
  289.     }
  290.     
  291.     
  292.     /**
  293.      * Method set_renda_mensal
  294.      * Sample of usage: $comp_fam->renda_mensal = $object;
  295.      * @param $object Instance of RendaMensal
  296.      */
  297.     public function set_renda_mensal(RendaMensal $object)
  298.     {
  299.         $this->renda_mensal $object;
  300.         $this->renda_mensal_id $object->id;
  301.     }
  302.     
  303.     /**
  304.      * Method get_renda_mensal
  305.      * Sample of usage: $comp_fam->renda_mensal->attribute;
  306.      * @returns RendaMensal instance
  307.      */
  308.     public function get_renda_mensal()
  309.     {
  310.         // loads the associated object
  311.         if (empty($this->renda_mensal))
  312.             $this->renda_mensal = new RendaMensal($this->renda_mensal_id);
  313.     
  314.         // returns the associated object
  315.         return $this->renda_mensal;
  316.     }
  317.     
  318.     //set para renda complementar
  319.     public function set_renda_compl(RendaCompl $object)
  320.     {
  321.         $this->renda_compl $object;
  322.         $this->renda_compl $object->id;
  323.     }
  324.     
  325.     //get para renda complementar
  326.     public function get_renda_compl()
  327.     {
  328.         // loads the associated object
  329.         if (empty($this->renda_compl))
  330.             $this->renda_compl = new RendaCompl($this->renda_compl_id);
  331.     
  332.         // returns the associated object
  333.         return $this->renda_compl;
  334.     }
  335.     
  336.     
  337.     
  338. }
MO

Classe Grauparent (Relacionada com CompFam) - quero pegar o nome do parentesco dessa classe

  1. <?php
  2. /**
  3.  * Grauparent Active Record
  4.  * @author  <your-name-here>
  5.  */
  6. class Grauparent extends TRecord
  7. {
  8.     const TABLENAME 'grauparent';
  9.     const PRIMARYKEY'id';
  10.     const IDPOLICY =  'serial'// {max, serial}
  11.     
  12.     
  13.     /**
  14.      * Constructor method
  15.      */
  16.     public function __construct($id NULL$callObjectLoad TRUE)
  17.     {
  18.         parent::__construct($id$callObjectLoad);
  19.         parent::addAttribute('grauparentesco');
  20.     }
  21. }
MO

Resumindo gostaria de fazer da seguinte forma, pegando o valor: $compfam->grauparent->grauparentesco

$titular = new Titular(2);
$compfam = $titular->getCompfams();

foreach ($titular->getCompfams() as $compfam)
{
print $compfam->compf_nome . ' - '. $compfam->compf_titular_id . $compfam->grauparent->grauparentesco.'
';
}
NR

O nome do atributo no model CompFam é compf_grauparent_id:
  1. <?php
  2. parent::addAttribute('compf_grauparent_id'); 
  3. ?>

Mas na função get_grauparent você está usando grauparent_id:
  1. <?php
  2. public function get_grauparent()
  3.     {
  4.         // loads the associated object
  5.         if (empty($this->grauparent))
  6.            $this->grauparent = new Grauparent($this->grauparent_id); //aqui deve ser o mesmo nome do atributo definido na setAttribute, grauparent_id nao existe
  7.     
  8.         // returns the associated object
  9.         return $this->grauparent;
  10.     } 
  11. ?>
MO

Isso mesmo deu certo, obrigado não estava enxergando, vlw!!