所以我有一段代码已经在我的localhost和开发服务器上工作了几个月。两者都是Windows环境。当移动到新的linux托管位置时,它会抛出这些错误:
警告(2):array_merge()[function.array-merge]:参数#2不是数组[CORE / Cake / Model / Model.php,第2036行]
警告(2):array_merge()[function.array-merge]:参数#2不是数组[CORE / Cake / Model / 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');
}
}
}
数据仍然保存得很好,但是如何更改它以便不会丢失这些错误?
答案 0 :(得分:2)