本文整理汇总了PHP中Vehicle::getVehicle方法的典型用法代码示例。如果您正苦于以下问题:PHP Vehicle::getVehicle方法的具体用法?PHP Vehicle::getVehicle怎么用?PHP Vehicle::getVehicle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vehicle
的用法示例。
在下文中一共展示了Vehicle::getVehicle方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: consumption
public static function consumption($v)
{
$vid = Vehicle::getVehicle($v);
$users = User::getUserIDs($vid["idvehicle"]);
if ($users != NULL) {
$uid = array();
//usersIDs
foreach ($users as $key => $value) {
array_push($uid, intval($users[$key]["iduser"]));
}
$consumption = array();
//consumption by userID
foreach ($uid as $key => $value) {
$data = Data::getDataBrowse($value);
if ($data != NULL && $data["max"] != NULL && $data["min"] != NULL && $data["fuel"] != NULL) {
$avg = intval($data["fuel"]) / (intval($data["max"]) - intval($data["min"])) * 100;
array_push($consumption, $avg);
}
}
if (!empty($consumption)) {
$avg = round(array_sum($consumption) / count($consumption), 2) . "L/100km";
$min = round(min($consumption), 2) . "L/100km";
$max = round(max($consumption), 2) . "L/100km";
return [$avg, $min, $max];
}
}
}
示例2: filter_input
<?php
require_once 'Vehicle.php';
require_once 'db_init.php';
$isPost = filter_input(INPUT_SERVER, 'REQUEST_METHOD') == 'POST';
$invalid = TRUE;
$message = "Invalid input!";
if ($isPost) {
$rules = array('vehicle_name' => array('filters' => FILTER_SANITIZE_SPECIAL_CHARS, 'filter' => FILTER_VALIDATE_REGEXP, 'options' => array("regexp" => "/^[a-zA-Z\\s0-9]{2,45}\$/")));
$sent = filter_input_array(INPUT_POST, $rules);
$exists = Vehicle::getVehicle($sent["vehicle_name"]);
if ($exists == NULL && $sent["vehicle_name"] != FALSE && $sent["vehicle_name"] != NULL) {
try {
Vehicle::addVehicle($sent["vehicle_name"]);
header("Location: ../html/admin.php");
} catch (PDOException $e) {
die($e->getMessage());
}
} else {
$message = $message . " Vehicle already exists!";
}
}
if ($invalid) {
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Invalid</title>
<link href='https://fonts.googleapis.com/css?family=Open+Sans+Condensed:300' rel='stylesheet' type='text/css'>
示例3: filter_input
<?php
require_once 'User.php';
require_once 'Vehicle.php';
require_once 'db_init.php';
$isPost = filter_input(INPUT_SERVER, 'REQUEST_METHOD') == 'POST';
$invalid = TRUE;
$message = "Invalid input!";
if ($isPost) {
$rules = array('full_nameSU' => array('filters' => FILTER_SANITIZE_SPECIAL_CHARS, 'filter' => FILTER_VALIDATE_REGEXP, 'options' => array("regexp" => "/^[a-zA-Z\\s,.-]{6,22}\$/")), 'e_mailSU' => array('filters' => FILTER_SANITIZE_SPECIAL_CHARS, 'filter' => FILTER_VALIDATE_REGEXP, 'options' => array("regexp" => "/^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\\.[a-zA-Z0-9-.]+\$/")), 'usernameSU' => array('filters' => FILTER_SANITIZE_SPECIAL_CHARS, 'filter' => FILTER_VALIDATE_REGEXP, 'options' => array("regexp" => "/^[a-zA-Z0-9_-]{5,16}\$/")), 'passwordSU' => array('filter' => FILTER_VALIDATE_REGEXP, 'options' => array("regexp" => "/^[a-zA-Z0-9_-]{6,18}\$/")), 'passwordSUC' => array('filter' => FILTER_VALIDATE_REGEXP, 'options' => array("regexp" => "/^[a-zA-Z0-9_-]{6,18}\$/")));
$sent = filter_input_array(INPUT_POST, $rules);
$exists = User::getUser($sent["usernameSU"]);
$v = filter_input(INPUT_POST, "vehicleSU", FILTER_SANITIZE_STRING);
$vehicle = Vehicle::getVehicle($v);
$vid = $vehicle["idvehicle"];
if ($exists == NULL && $sent["passwordSU"] == $sent["passwordSUC"]) {
try {
$hash = password_hash($sent["passwordSU"], PASSWORD_DEFAULT);
User::addUser($sent["usernameSU"], $sent["e_mailSU"], $sent["full_nameSU"], $hash, $vid);
header("Location: ../index.php");
} catch (PDOException $e) {
die($e->getMessage());
}
} else {
$message = $message . " Username already exists!";
}
}
if ($invalid) {
?>
<!DOCTYPE html>