这是我的url链接和设备返回浏览器正文中的相应值。现在我将此数据插入到我的数据库表名IpRelay
中。首先,我爆炸我的设备返回数据。然后我试图插入爆炸数据。
这是我的代码。但它不起作用。
public function get_data(){
$contents = file_get_contents('http://10.5.40.83');
function multiexplode ($delimiters,$string) {
$ready = str_replace($delimiters, $delimiters[0], $string);
$launch = explode($delimiters[0], $ready);
return $launch;
}
$get_device_data = multiexplode(array(",",":",), $contents);
$this->IpRelay->create();
$this->IpRelay->set($this->request->data['get_device_data']);
$save = $this->IpRelay->save();
echo $save ? "I've created the link" : "Error creating link!";
die($this->IpRelay->id);
}
我是cakephp的新手,我使用的是蛋糕版2.7.5。 你能帮我吗?
url=> http://10.5.40.83/
device return value=> 10,5,40,83:0,11,0,0,556
答案 0 :(得分:1)
$this->IpRelay->create();
$this->IpRelay->set($this->request->data['get_device_data']);
$save = $this->IpRelay->save();
echo $save ? "I've created the link" : "Error creating link!";
die($this->IpRelay->id);
而不是上面的代码我在这个代码下面使用它并且它正常工作
$this->IpRelay->read(null, 1);
$this->IpRelay->set(array(
'a' => $get_device_data[0],
'b' => $get_device_data[1],
'c' => $get_device_data[2],
'd' => $get_device_data[3],
'e' => $get_device_data[4],
'f' => $get_device_data[5],
'g' => $get_device_data[6],
'h' => $get_device_data[7],
'volt' => $get_device_data[8]
));
$this->IpRelay->save();
答案 1 :(得分:1)
希望它对您的
更容易和有帮助<?xml version="1.0" encoding="utf-8" standalone="no"?>
<test-run id="2" testcasecount="596" result="Failed" total="596" passed="448" failed="148" inconclusive="0" skipped="0" asserts="812" engine-version="3.6.0.0" clr-version="4.0.30319.42000" start-time="2017-01-30 07:19:45Z" end-time="2017-01-30 07:31:25Z" duration="700.676581">