CakePHP - page using more than one table

6

I have a question, about saving data in the database using CakePHP, when I need to manipulate with more than one table. I am creating a customer registration system and it has a system for registering login's and client's passwords, such as control panel, database, etc.

The database structure

Customers

Have fields with customer data, such as phone, email, etc.

Options

  
  • id
  •   
  • option (option name, such as control panel, database, etc.)
  •   
  • user_aut (field to indicate if this option is going to have user fill)
  •   
  • host_ativ (field to indicate if host / ip, as database ... control panel would not have this option
  •   

rel_op_client

  
  • customer_id
  •   
  • id_option
  •   
  • password
  •   
  • host
  •   
  • user
  •   

I managed to solve the question of the form appearing data, in the client controller I put public $uses = array('Cliente','Opcao', 'RelInfoCliente'); and with this he can capture the data of the 3 tables ... but in case of saving the data of the form, which would be the best way to save the client save the data of the options, if I change the user name change in table rel_op_cliente

    
asked by anonymous 24.04.2014 / 16:14

1 answer

1

Resolved issue

public  $hasAndBelongsToMany  =  array (
    'opcoes_clientes'  =>  array (
        'className'  =>  'opcoes' ,
        'joinTable' => 'rel_infos_clientes',
        'foreignKey'  =>  'id_cliente' ,
        'associationForeignKey'  => 'id_opcao',
        'dependent'  =>  true
    )
);

In case I'm just changing the table name to stay within the convention, but now I get it. joinTable would be the middle table and in classname would be the class with the "net" table ...

    
25.04.2014 / 21:06