$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问题还是我做了一些错误..任何形式的帮助将不胜感激。 仍然没有解决......任何人都试过了?
答案 0 :(得分:0)
也许你需要加载你正在使用的模型,所以:
$this->loadModel('Order');
$b = $this->Order->saveAll( $data )