本文整理汇总了PHP中Driver::add方法的典型用法代码示例。如果您正苦于以下问题:PHP Driver::add方法的具体用法?PHP Driver::add怎么用?PHP Driver::add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Driver
的用法示例。
在下文中一共展示了Driver::add方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: switch
require_once '../../../framework/Driver.php';
if (isset($_GET['action'])) {
$action = $_GET['action'];
} else {
$action = "";
}
switch ($action) {
case "add":
$name = $_POST['name'];
$phone = $_POST['phone'];
$address = $_POST['address'];
$date = $_POST['date_join'];
$dateJoin = date("Y-m-d", strtotime($date));
$description = $_POST['description'];
if (Driver::add($name, $phone, $address, $description, $dateJoin)) {
header('Location:index.php');
}
break;
case "update":
$id = $_POST['id'];
$phone = $_POST['phone'];
$address = $_POST['address'];
$description = $_POST['description'];
$mDriver = new Driver($id);
if ($mDriver->update($phone, $address, $description)) {
header('Location: ' . $_SERVER['HTTP_REFERER']);
} else {
header('Location:index.php');
}
break;
示例2: driver_controller
//.........这里部分代码省略.........
}
$tmp = array();
foreach ($inputs as $name => $value)
{
if (!isset($dbinputs[$nodeid][$name])) {
$inputid = $input->create_input($userid, $nodeid, $name);
$dbinputs[$nodeid][$name] = true;
$dbinputs[$nodeid][$name] = array('id'=>$inputid, 'processList'=>'');
$input->set_timevalue($dbinputs[$nodeid][$name]['id'],$time,$value);
} else {
$inputid = $dbinputs[$nodeid][$name]['id'];
$input->set_timevalue($dbinputs[$nodeid][$name]['id'],$time,$value);
if ($dbinputs[$nodeid][$name]['processList']) $tmp[] = array('value'=>$value,'processList'=>$dbinputs[$nodeid][$name]['processList']);
}
}
foreach ($tmp as $i) $process->input($time,$i['value'],$i['processList']);
} else { $valid = false; $error = "Format error, time index given is negative"; }
} else { $valid = false; $error = "Format error, bulk item needs at least 3 values"; }
}
} else { $valid = false; $error = "Format error, time index given is negative"; }
} else { $valid = false; $error = "Format error, last item in bulk data does not contain any data"; }
} else { $valid = false; $error = "Format error, json string supplied is not valid"; }
if ($valid) $result = 'ok'; else $result = "Error: $error\n";
}
// input/post.json?node=10&json={power1:100,power2:200,power3:300}
// input/post.json?node=10&csv=100,200,300
*/
if ($route->action == 'add') {
$datain = false;
// code below processes input regardless of json or csv type
if (isset($_GET['json'])) {
$datain = get('json');
}
if ($datain != "") {
$json = preg_replace('/[^\\w\\s-.:,]/', '', $datain);
$datapairs = explode(',', $json);
$csvi = 0;
$description = "";
for ($i = 0; $i < count($datapairs); $i++) {
$keyvalue = explode(':', $datapairs[$i]);
if (isset($keyvalue[1])) {
if ($keyvalue[0] != 'type' or $keyvalue[0] != 'description') {
$valid = false;
$error = "Format error, json key missing or invalid character";
}
if ($keyvalue[0] == 'type') {
$driverid = $keyvalue[1];
} else {
$description = $keyvalue[1];
}
}
}
$userid = $session['userid'];
$result = $driver->add($userid, $driverid, $description);
$valid = true;
} else {
$valid = false;
$error = "Request contains no data via csv, json or data tag";
}
if (!$valid) {