【问题标题】:Saveall issue with multiple associated model in cakephp 1.3cakephp 1.3 中多个关联模型的 Saveall 问题
【发布时间】:2014-12-28 04:45:09
【问题描述】:
$data['Order']['amount'] = 10;
$data['Orderdetail'] = array( 
     0 => array( 'unitprice' => 1, 'amount' => 2, 'discount' => 1, 'skunit_id' => 1,                    
        'batch_id' => 0, 'vat' => 0, 'schemediscount' => 0, 'quantity' => 1, 'amount' => 10 ), 
   1=> array( 'unitprice' => 1, 'amount' => 2, 'discount' => 1, 'skunit_id' => 1,   
       'batch_id' => 0, 'vat' => 0, 'schemediscount' => 0, 'quantity' => 1, 'amount' => 10 ));

$b = $this->Order->saveAll( $data )

我正在使用此代码。我还在模型中定义了关联,例如

var $hasMany = array(
    'Orderdetail' => array(
        'className' => 'Orderdetail',
        'foreignKey' => 'order_id',
        'dependent' => false,
        'conditions' => '',
        'fields' => '',
        'order' => '',
        'limit' => '',
        'offset' => '',
        'exclusive' => '',
        'finderQuery' => '',
        'counterQuery' => ''
    ));

但是这两个数据都没有保存..是 cakephp 1.3 问题还是我做错了..任何形式的帮助都将不胜感激。 还没有解决……有没有人试过??

【问题讨论】:

    标签: cakephp cakephp-1.3


    【解决方案1】:

    也许您需要加载您正在使用的模型,所以:

    $this->loadModel('Order');
    $b = $this->Order->saveAll( $data )
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-08-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-06
      相关资源
      最近更新 更多