Relationship between table A and B returns error because it calls data from table C in CakePhP

0

I am 3 days beating headache with a problem: I have some tables in the system and this error happens in the most improbable screens.

I'll give you the latest example:

  

2015-03-13 16:37:51 Error: [PDOException] SQLSTATE [42S22]: Column not   found: 1054 Unknown column 'CadRepresentante.id' in 'field list'   Request URL: / lhasa / auxiliary / situacao_banco / edit / 18
  # 8 C: \ xampp \ htdocs \ lhasa \ app \ Controller \ BankController.php (87):   Model-> read (NULL, '18')
  # 9 [internal function]: SituationBancoController-> helper_edit ('18 ')

The AuxSituationBank table has $ hasMany binding with CadPropose, but no binding with CadRepresentant! If I remove the link with CadProposta in the model of AuxSituacaoBanco, stop giving the editing error, but then in CadProposta, which has $ belongsTo connection, it starts to give error of the AuxSituacaoBanco.

I no longer know what to do to solve this problem!

AuxSituacaoBanco:

public $hasMany = array(
    'CadProposta' => array(
        'className' => 'CadProposta',
        'foreignKey' => 'aux_situacao_banco_id',
    )
);

CadProposta

public $belongsTo = array(
...
    'AuxSituacaoBanco' => array(
        'className' => 'AuxSituacaoBanco',
        'foreignKey' => 'aux_situacao_banco_id',
    ),
...
);
    
asked by anonymous 13.03.2015 / 20:53

1 answer

0

You did not put there but probably the model CadPropose should have a belongsTo association with CadRepresentante

'CadRepresentante' => array(
        ....
)

add this line

'CadRepresentante' => array(
       'fields' => array('CadRepresentante.id'),
)

There is one other thing you can do if you do not need the proposal data in the edit of the BankSetup in the first line of the edit function inside the controller you can leave the model's recursion in -1 that way it did not seek data from any relationship . $ this-> AuxSituacaoBanco-> recursive = -1;

link

    
10.04.2015 / 15:25