本文整理汇总了PHP中Controlador::inserProduct方法的典型用法代码示例。如果您正苦于以下问题:PHP Controlador::inserProduct方法的具体用法?PHP Controlador::inserProduct怎么用?PHP Controlador::inserProduct使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Controlador
的用法示例。
在下文中一共展示了Controlador::inserProduct方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
public static function run()
{
$miLogic = new Controlador();
$view = isset($_GET['view']) ? $_GET['view'] : 'default';
switch ($view) {
case 'default':
$productos = $miLogic->getProductos();
break;
case 'agregar':
$miLogic->agregarProductos($_GET['id']);
header('location:ViewPHP.php');
break;
case 'update':
$miLogic->actualizarCarrito();
header('location:ViewPHP.php?view=detalle');
break;
case 'cerrar':
$miLogic->cerrarSesion();
break;
case 'detalle':
$productos = $miLogic->getProductos();
break;
case 'presentar':
$name = $_POST['name'];
$address = $_POST['address'];
$city = $_POST['city'];
$province = $_POST['province'];
$email = $_POST['email'];
$country = $_POST['country'];
$shippingMethod = $_POST['shippingMethod'];
$paymentMethod = $_POST['paymentMethod'];
$zipCode = $_POST['zipCode'];
$phone = $_POST['phone'];
$orden = $miLogic->crearOrden($name, $address, $city, $province, $email, $country, $shippingMethod, $paymentMethod, $zipCode, $phone);
break;
case 'imagen':
$imagen = $miLogic->loadImage($_GET['id']);
header('Content-type:image/png');
echo $imagen->getBytes();
break;
case 'login':
if (isset($_POST['username']) && isset($_POST['pwd'])) {
if ($_POST['username'] != null && $_POST['pwd'] != null) {
$r_username = $_POST['username'];
$r_pwd = $_POST['pwd'];
$userLogic = new UserLogic();
$rs = $userLogic->auth($r_username, $r_pwd);
header('location:ViewPHP.php');
}
}
break;
case 'register':
echo $username = $_POST['username'];
echo $pwd = $_POST['pwd'];
echo $role = 'customer';
$userLogic = new UserLogic();
$created = $userLogic->create($username, $pwd, $role);
$rs = $userLogic->auth($username, $pwd);
echo var_dump($rs);
// $username = $_POST['username'];
// $pwd = $_POST['pwd'];
// $role = 'customer';
// $userLogic = new UserLogic();
// $created = $userLogic->create($username, $pwd, $role);
// echo $created;
// if ($created) {
// $rs = $userLogic->auth($username, $pwd);
// header('location:ViewPHP.php');
// } else {
// // TODO: handle errors
// header('location:ViewPHP.php');
// }
break;
case 'addProduct':
if (isset($_POST['name'])) {
if ($_POST['name'] != null && $_POST['description'] != null && $_POST['price'] != null && $_FILES['img'] != null) {
$name = $_POST['name'];
$description = $_POST['description'];
$price = $_POST['price'];
$img = $_FILES['img'];
$nameimg = $_FILES['img']['name'];
$path = getcwd();
$path = substr($path, 0, 35);
$mvpath = '../imagenes/' . $nameimg;
$tmp_name = $_FILES['img']['tmp_name'];
move_uploaded_file($tmp_name, $mvpath);
$status = $miLogic->inserProduct($name, $description, $price, $mvpath);
header('location:ViewPHP.php?view=default');
}
}
break;
case 'deleteProduct':
if (isset($_POST['id'])) {
if ($_POST['id'] != null) {
$status = $miLogic->deleteProduct($_POST['id']);
header('location:ViewPHP.php');
}
}
break;
default:
//.........这里部分代码省略.........