1
所以我有一段代碼已經在我的本地主機和開發服務器上工作了好幾個月。這兩者都是Windows環境。當移動到一個新的Linux託管位置它會引發這些錯誤:cakephp saveall錯誤參數#2不是數組
警告(2):array_merge()[function.array-merge]:參數#2不是數組[CORE/Cake/Model/Model.php行2036]
警告(2):array_merge()[function.array合併]:參數#2不是數組[CORE /蛋糕/型號/ Model.php,線2186]
的有問題的一段代碼是saveAll調用,用於保存從表單中檢索到的數據。有趣的是,儘管出現錯誤,數據仍可以保存。
我的代碼保存在這裏
if (!($quote['Quote']['total'] == 0 || $quote['Quote']['total'] < 0)) {
if ($this->Quote->saveAll($quote, true)) {
$this->Session->setFlash('Quote Saved', 'success');
$this->redirect('/clientcases/view/' . $case . '#tab6');
}
整個功能:
public function makeQuote() {
$this->loadModel('Applicant');
$this->LoadModel('ApplicantQuote');
$this->LoadModel('Setfee');
$this->LoadModel('Clientcase');
$this->LoadModel('Internalprice');
$this->LoadModel('Clientprice');
/* ------ retrieving client and internal prices for display ------ */
$internal = $this->Internalprice->find('all');
$client = $this->Clientprice->find('all');
//retrieves the applicants chosen from the view_quotes page
$args = $this->params['url'];
//get the case id from the previous page
$case = $args['data']['caseid'];
//remove move some unnecessary things from the args array
unset($args['data']['caseid']);
unset($args['id']);
//retrieve the applicant information from the database using the applicant array
$applicants = $this->Applicant->find('all', array('conditions' => array('id' => $args['data']),
'order' => 'first_name ASC', 'recursive' => -1));
$app_id = Set::classicExtract($applicants, '{n}.Applicant.id');
if ($applicants == null) {//redirect back to view quotes page if no applicants were chosen
$this->Session->setflash('Choose at least one applicant');
$this->redirect('/clientcases/view/' . $case . '#tab5');
}
$this->set(compact('applicants', 'case', 'args', 'internal', 'client'));
if ($this->request->is('post')) {
$cancelCheck = $_POST;
if ($cancelCheck['QuoteButton'] == 'Cancel') {
$this->redirect('/clientcases/view/' . $case);
}
$quote = $this->request->data;
unset($quote['QuoteButton']);
$quote["Applicant"] = array();
$quote['Applicant']['Applicant'] = array();
$count = 0;
foreach ($app_id as $key => $id) {
$quote['Applicant']['Applicant'][] = $app_id[$count];
$count++;
}
$gst = 0;
if ($quote['Quote']['includeGST'] == 1) {
$total = $quote['Quote']['total'];
if ($total > 0) {
$gst = $total/10;
}
}
$quote['Quote']['GST'] = $gst;
//debug($quote);
unset($quote['Quote']['includeGST']);
if (!($quote['Quote']['total'] == 0 || $quote['Quote']['total'] < 0)) {
if ($this->Quote->saveAll($quote, true)) {
$this->Session->setFlash('Quote Saved', 'success');
$this->redirect('/clientcases/view/' . $case . '#tab6');
}
} else {
$this->Session->setflash('Quote Failed to Save, All fields must be filled in and total greater than 0');
}
}
}
的數據仍然保存得很好,但我要如何改變它,這樣它不會拋出這些錯誤?
我不認爲只是保存會起作用。該表格試圖一次保存到5個不同的表格。 – user2787386