我在 Apicontroller.php 中有功能订单,我已经做了一个注释列,但为什么它不想要记录列存储数据库到订单,我很困惑,找到数据插入过程在 CakePHP 的位置,但发送电子邮件已经成功,有我的代码:
public function Order()
{
$status = false;
$message = ERR_04;
$code = "04";
$request["Order"]["service_id"] = empty($_REQUEST["service_id"]) ? "" : $_REQUEST["service_id"];
$request["Order"]["user_id"] = empty($_REQUEST["user_id"]) ? "" : $_REQUEST["user_id"];
$request["Order"]["fullname"] = empty($_REQUEST["fullname"]) ? "" : $_REQUEST["fullname"];
$request["Order"]["email"] = empty($_REQUEST["email"]) ? "" : $_REQUEST["email"];
$request["Order"]["phone"] = empty($_REQUEST["phone"]) ? "" : $_REQUEST["phone"];
$request["Order"]["gender"] = empty($_REQUEST["gender"]) ? "" : $_REQUEST["gender"];
$request["Order"]["address"] = empty($_REQUEST["address"]) ? "" : $_REQUEST["address"];
$request["Order"]["lt"] = empty($_REQUEST["lt"]) ? "0" : $_REQUEST["lt"];
$request["Order"]["unit"] = empty($_REQUEST["unit"]) ? "0" : $_REQUEST["unit"];
$request["Order"]["city_id"] = empty($_REQUEST["city_id"]) ? "" : $_REQUEST["city_id"];
$request["Order"]["district_id"] = empty($_REQUEST["district_id"]) ? "" : $_REQUEST["district_id"];
$request["Order"]["village_id"] = empty($_REQUEST["village_id"]) ? "" : $_REQUEST["village_id"];
$request["Order"]["date_order"] = empty($_REQUEST["date_order"]) ? "" : $_REQUEST["date_order"];
$request["Order"]["time_order"] = empty($_REQUEST["time_order"]) ? "" : $_REQUEST["time_order"];
$request["Order"]["time_finish"] = empty($_REQUEST["time_finish"]) ? "" : $_REQUEST["time_finish"];
$request["Order"]["building_id"] = empty($_REQUEST["building_id"]) ? "" : $_REQUEST["building_id"];
//"注意"变量无法保存在数据库中
$request["Order"]["note"] = empty($_REQUEST["note"]) ? "" : $_REQUEST["note"];
//我不知道为什么
$request["Order"]["total_maid"] = empty($_REQUEST["total_maid"]) ? "1" : $_REQUEST["total_maid"];
$request["Order"]["total_shift"] = empty($_REQUEST["total_shift"]) ? "1" : $_REQUEST["total_shift"];
$request["Order"]["different_gender"] = empty($_REQUEST["different_gender"]) ? "0" : $_REQUEST["different_gender"];
$request["Order"]["price"] = empty($_REQUEST["price"]) ? "0" : $_REQUEST["price"];
$request["Order"]["total"] = $request["Order"]["total_maid"] * $request["Order"]["total_shift"] * $request["Order"]["price"];
$request["Order"]["duration"] = empty($_REQUEST["duration"]) ? "0" : $_REQUEST["duration"];
$timeCoonvert = strtotime($request["Order"]["date_order"]." ".$request["Order"]["time_order"].":00");
$request["Order"]["expired_order"] = date("Y-m-d H:i:s",mktime(date("H")+5,date("i"),date("s"),date("m"),date("d"),date("Y")));
$this->loadModel('Order');
$this->Order->ValidateCheckout();
$this->Order->set($request);
$error = $this->Order->InvalidFields();
if(empty($error))
{
$status = true;
$message = ERR_00;
$code = "00";
$save = $this->Order->save($request,array("validate"=>false));
$ID = $this->Order->getLastInsertId();
$this->Order->BindAll(false);
$data = $this->Order->find('first',array(
'conditions' => array(
'Order.id' => $ID
)
));
$different_gender = ($request["Order"]["different_gender"] == "1") ? "Ya" : "Tidak";
/****************** EMAIL NOTIFICATION ************************/
$search = array(
'[web_url]',
'[logo_url]',
'[cms_url]',
'[order_id]',
'[fullname]',
'[phone]',
'[address]',
'[email]',
'[date_order]',
'[time_order]',
'[total_maid]',
'[different_gender]',
'[total_shift]',
'[bank]',
'[total]'
);
$replace = array(
$this->settings["web_url"],
$this->settings["logo_url"],
$this->settings["cms_url"],
$data["Order"]["order_id_display"],
ucwords(strtolower($data["Order"]["fullname"])),
$data["Order"]["phone"],
$data["Order"]["address"]."<br/>".ucfirst($data["Village"]["name"])."<br/>".ucfirst($data["District"]["name"])."<br/>".ucfirst($data["City"]["name"]),
$request["Order"]["email"],
date("d M Y",strtotime($data["Order"]["date_order"])),
substr($data["Order"]["time_order"],0,-3),
$data["Order"]["total_maid"],
$different_gender,
$data["Order"]["total_shift"],
str_replace("\n","<br/>",$this->settings['bank_payment']),
"Rp ".number_format($data["Order"]["total"],0,null,",")
);
$this->Action->EmailSend('order', trim($request['Order']['email']), $search, $replace,array(),array(),"Order",$ID,"");
$this->Action->EmailSend('order', "customer@gomaid.co.id", $search, $replace,array(),array(),"Order",$ID,"");
/****************** EMAIL NOTIFICATION ************************/
}
else
{
$status = false;
foreach($error as $k => $v)
{
$message = $v[0];
break;
}
$code = "03";
$data = null;
}
$out = array("status"=>$status,"message"=>$message,"data"=>$data,"code"=>$code,"request"=>$_REQUEST,"files"=>$_FILES);
$json = json_encode($out);
echo $json;
pr($out);
}
这是我收到的电邮....
但这是我的表订单在备注栏中仍然是空的....
有没有解决方案?我非常困难,我是CakePHP的新手,请帮助我...我使用Eclipse代码Android将带有CakePHP的数据发送到数据库。
答案 0 :(得分:0)
为了能够面对这个问题的其他人,这些是后续步骤:
app/tmp/cache/model/*
所有文件。debug
模式设为2
。app/tmp
目录可写。注意:对数据库架构的任何更改都需要遵循1
的{{1}}或2
步骤来检测所做的更改。