<?php

namespace App\Models;

use CodeIgniter\Model;

class Product_model extends Model
{
    public function getProducts($productId = '') {
        $db = db_connect();
        if (trim($productId) == '' ){
            $mysql = "SELECT * FROM products ORDER BY id ASC ";
            $query = $db->query($mysql);
            return $query->getResult('array');
        }else
        {
            $mysql = "SELECT * FROM products WHERE product_id='$productId' ";
            $query = $db->query($mysql);
            return $query->getResult('array')[0];
        }


//        $query = $db->query($mysql);
//        return $query->getResult('array')[0];
    }


}