cakephp - Update only a table, but the table is associated with another -
i have main table, cliente. table associated 20 tables. i´m trying update table clientee using code below:
$this->cliente->updateall(array("ec_cnpj" => $this->request->data['cliente']['ec_cnpj'], "ec_cpf" => $this->request->data['cliente']['ec_cpf'], "ec_rg" => $this->request->data['cliente']['ec_rg'], "ec_rg_org_emissor" => $this->request->data['cliente']['ec_rg'], "ec_rg_est_emissor" => $this->request->data['cliente']['ec_rg_est_emissor'], "ec_nire" => $this->request->data['cliente']['ec_nire']), array("ec_codigo"=>$this->request->data['ec_codigo']))
but, cake generating query update tables. how can update cliente table?
from the docs
by default, updateall() automatically join belongsto association databases support joins. prevent this, temporarily unbind associations.
so, unbind correspondent models like
$this->cliente->unbindmodel(array('hasmany' => array('table1', 'table2')));
read "creating , destroying associations on fly" have better understanding of it.
maybe you'll find this useful, escapes comes directly cakephp, you'll have create new function.
Comments
Post a Comment