当前位置: 首页>>代码示例>>PHP>>正文


PHP Controlador::getProductos方法代码示例

本文整理汇总了PHP中Controlador::getProductos方法的典型用法代码示例。如果您正苦于以下问题:PHP Controlador::getProductos方法的具体用法?PHP Controlador::getProductos怎么用?PHP Controlador::getProductos使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Controlador的用法示例。


在下文中一共展示了Controlador::getProductos方法的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:
//.........这里部分代码省略.........
开发者ID:parameshvec,项目名称:shopcart-mongodb-php,代码行数:101,代码来源:ViewPHP.php


注:本文中的Controlador::getProductos方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。