Example #1
0
function api_autoloader($class_name)
{
    $directory = '../class/';
    if (file_exists($directory . $class_name . '.class.php')) {
        require_once $directory . $class_name . '.class.php';
        return;
    }
}
spl_autoload_register('api_autoloader');
//$app = \Slim\Slim::getInstance();
//$db = new dbHelper();
$db = new db(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_DATABASE);
// Products
$app->get('/products', function () {
    $product = new product();
    $response = $product->getAllProduct();
    echoResponse(200, $response);
});
$app->post('/products', function () use($app) {
    $product = new product();
    $data = json_decode($app->request->getBody(), TRUE);
    $id = $product->AddProduct($data);
    echoResponse(200, $id);
});
$app->put('/products/:id', function ($id) use($app) {
    $product = new product();
    $data = json_decode($app->request->getBody(), TRUE);
    $result = $product->updateProduct($id, $data);
    // $rows["message"] = "Product information updated successfully.";
    echoResponse(200, $result);
});
Example #2
0
<?php

require_once '../models/class-product.php';
//require_once('../models/class-cat-product.php');
require_once '../models/class-phan-trang.php';
$product_obj = new product();
$config = array('current_page' => isset($_GET['page']) ? $_GET['page'] : 1, 'total_record' => $product_obj->countTable('product'), 'limit' => 3, 'link_full' => 'index.php?view=list-product&page={page}', 'link_first' => 'index.php?view=list-product', 'range' => 9);
$start = ($config['current_page'] - 1) * $config['limit'];
$sort = '';
if (isset($_GET['sort'])) {
    $sort = $_GET['sort'];
}
switch ($sort) {
    case 'pro_name':
        $a = $product_obj->getAllProduct('pro_name', array($start, $config['limit']));
        break;
    default:
        $a = $product_obj->getAllProduct('', array($start, $config['limit']));
}
?>
    <table class="table table-bordered table-striped table-condensed flip-content">
        <thead class="flip-content">
            <tr>
                <th>STT</th>
                <th><a href="index.php?view=list-news&sort=title">Sản phẩm</a></th>
                 <th class="numeric">Ảnh</th>
                 <th class="numeric">Mã</th>
                 <th class="numeric">Màu sắc</th>
                 <th class="numeric">Giá niêm yết</th>
                 <th width="10%" class="numeric">Ngày đặt</th>
                  <th class="numeric">Giá sale</th>