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

Curso Dominando o Adianti Framework

O material mais completo de treinamento do Framework.
Curso em vídeo aulas + Livro completo + Códigos fontes do projeto ERPHouse.
Conteúdo Atualizado!


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

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