Cakephp 如何在控制器中保存影响数据库中一个表的两个不同信息

Cakephp 如何在控制器中保存影响数据库中一个表的两个不同信息,cakephp,cakephp-2.1,Cakephp,Cakephp 2.1,我不知道如何同时在数据库中保存不同的值。我有这个想法 <?php echo $this->Form->create('SoyaPrecioInternacional');?> <fieldset> <?php echo $this->Form->input('pais', array( 'options' => array( 'CHICAGO

我不知道如何同时在数据库中保存不同的值。我有这个想法

<?php echo $this->Form->create('SoyaPrecioInternacional');?>
    <fieldset> 

        <?php 
        echo $this->Form->input('pais', array(
            'options' => array( 
            'CHICAGO' => 'Chicago', 
            'ROSARIO' => 'Rosario'
                ),'label'=>'Ciudad'
        ));
        echo $this->Form->input('precio', array('label' => 'Ingrese en Dolares $us','style'=>'width:500px; height:30px;'));
                echo $this->Form->input('pais', array(
            'options' => array( 
            'CHICAGO' => 'Chicago', 
            'ROSARIO' => 'Rosario'
                ),'label'=>'Ciudad'
        ));
        echo $this->Form->input('precio', array('label' => 'Ingrese en Dolares $us','style'=>'width:500px; height:30px;'));
        echo $this->Form->submit('Agregar Cambio', array('class' => 'form-submit',  'title' => 'Presione aqui para agregar datos')); 
    ?>
</fieldset>
但当我在控制器中为选项1和选项2分别定价时,只得到最后一个选项表单示例 如果我为芝加哥第一个选项定价,然后罗萨里奥第二个选项在我的db中只显示罗萨里奥值

<?php echo $this->Form->create('SoyaPrecioInternacional');?>
    <fieldset> 
        <?php 
        echo $this->Form->input('SoyaPrecioInternacional.1.precio', array('label' => 'Ingrese en Dolares $us','style'=>'width:500px; height:30px;'));
        echo $this->Form->input('SoyaPrecioInternacional.1.pais', array('type' => 'hidden', 'value'=>'ROSARIO'));
            ?>

            <?php 
            echo $this->Form->input('SoyaPrecioInternacional.2.precio', array('label' => 'Ingrese en Dolares $us','style'=>'width:500px; height:30px;'));
            echo $this->Form->input('SoyaPrecioInternacional.2.pais', array('type' => 'hidden', 'value'=>'CHICAGO'));

        echo $this->Form->submit('Agregar Cambio', array('class' => 'form-submit',  'title' => 'Presione aqui para agregar datos')); 
    ?>

除了代码中明显存在的问题外,我认为如果您解释一下您的DB模式,也就是说,如果代码实际上是这样暗示的,那么您将如何以及为什么要为单个列存储多个值,对于获得更好的答案是有帮助的。如果您有两个表,我认为您有两个模型,对吗?如果你有两张桌子,这是可能的。首先确保你已经做了两个模型。谢谢@ndm…我的客户不喜欢这样…我觉得他太懒了!!他想为芝加哥和罗萨里奥省一次钱,这是我的问题,我不知道如何为一个模型保存两个表单……关于我的DB模式,我只有id、precio、pais和fecharegistro。当客户节省一个价格时,它就起作用了…请帮助。。
<?php echo $this->Form->create('SoyaPrecioInternacional');?>
    <fieldset> 
        <?php 
        echo $this->Form->input('SoyaPrecioInternacional.1.precio', array('label' => 'Ingrese en Dolares $us','style'=>'width:500px; height:30px;'));
        echo $this->Form->input('SoyaPrecioInternacional.1.pais', array('type' => 'hidden', 'value'=>'ROSARIO'));
            ?>

            <?php 
            echo $this->Form->input('SoyaPrecioInternacional.2.precio', array('label' => 'Ingrese en Dolares $us','style'=>'width:500px; height:30px;'));
            echo $this->Form->input('SoyaPrecioInternacional.2.pais', array('type' => 'hidden', 'value'=>'CHICAGO'));

        echo $this->Form->submit('Agregar Cambio', array('class' => 'form-submit',  'title' => 'Presione aqui para agregar datos')); 
    ?>
public function add()
{
    $this->loadModel('SoyaPrecioInternacional');

        $this->request->data['SoyaPrecioInternacional']['user_id'] = $this->Auth->user('id');
        if ($this->request->is('post')) {
            $count=0;
        foreach($this->request->data['SoyaPrecioInternacional'] as $precios){
            $count++;
            $this->SoyaPrecioInternacional->create();
            $this->request->data['SoyaPrecioInternacional']['precio']=$precios['precio'];
            $this->request->data['SoyaPrecioInternacional']['pais']=$precios['pais'];

            $this->SoyaPrecioInternacional->save($this->request->data);
        }
    return $this->redirect(array('action' => 'index'));
    }       

}