dousi1875 2015-09-02 14:53
浏览 16

Cakephp在行为中增加更新列

Good day!

I am running an update on two tables at once , but when I run the query cakephp is increasing the value of a column like a column with auto increment .

I have the following array:

$this->request->data = array(
        'Model1' => array(
            'id'=>'9',
            'nome_fantasia' => 'Campos',
            'razao_social' => 'Campos ',
            'email' => 'testes@teste.com.br',
            'responsavel_cpf' => '4456456465',
            'ativo' => '1'
        ),
        'Model2' => array(
            (int) 0 => array(
                'id' => '43',
                'relacionamento_id' => '9',
                'endereco' => 'Rua ******',
                'numero' => '123',
                'bairro' => 'bairro',
                'cep' => '033888222'
            )
        )
    );

And then the bass I have the update function:

$this->Modelo1->id = $this->request->data('Modelo1.id'); 
$this->Modelo1->saveAll( $this->request->data );

Ok , it does the Update in Model1 when it runs the update in Modelo2 it saves all the data but in the ' relacionamento_id ' instead of putting '9' as in this-> request- > data it is increasing with some ghost value. .. I realized that every time I run the query it will increase the number , for example

Attempt 1 = relacionamento_id = 50
Attempt 2 = relacionamento_id = 51
Attempt 3 = relacionamento_id = 52
Attempt 4 = relacionamento_id = 53

If I save both models separately it is right, but I would save direct .

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
    • ¥500 火焰左右视图、视差(基于双目相机)
    • ¥100 set_link_state
    • ¥15 虚幻5 UE美术毛发渲染
    • ¥15 CVRP 图论 物流运输优化
    • ¥15 Tableau online 嵌入ppt失败
    • ¥100 支付宝网页转账系统不识别账号
    • ¥15 基于单片机的靶位控制系统
    • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
    • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?