I do the withdrawal of goods by category, but an error occurs
Warning: PDOStatement :: execute (): SQLSTATE [HY093]: Invalid parameter number: not defined in (if the withdrawal of goods itself is not working, then I will be happy with criticism and advice) :) ProductController.php
class ProductModel extends Model { public function products($idcat){ $stmt=$this->db->prepare("SELECT id, name,price,description FROM products WHERE category_id = ?"); $stmt->bindParam('i',$idcat); $stmt ->execute(); $result = array(); $i=1; while($row = $stmt->fetch(PDO::FETCH_ASSOC)) { $result[$i]['id']=$row['id']; $result[$i]['name']=$row['name']; $result[$i]['description']=$row['descriprion']; $result[$i]['price']=$row['price']; $i++; } return $result; } } ProductController.php
require_once (MODEL_PATH ."/CategoryModel.php"); class ProductController extends Controller { private $pageTpl = "/Views/templates/product.tpl.php"; public function __construct() { $this->model=new ProductModel(); $this->view= new View(); } public function index(){ $this->pageData['title']="О нас"; $category=CategoryModel::Get_Category(); $this->pageData['category'] = $category; $idcat=$category['id_category'] ; $this->pageData['products']=$this->model->products($idcat); $this->view->render($this->pageTpl,$this->pageData); } } and for every CategoryModel.php
class CategoryModel extends Model { public static function Get_Category (){ $conn=DB::connToDB(); $sql="SELECT id, name FROM categories"; $result = array(); $stmt= $conn->prepare($sql); $stmt ->execute(); $i=1; while($row = $stmt->fetch(PDO::FETCH_ASSOC)) { $result[$i]['id']=$row['id']; $result[$i]['name']=$row['name']; $i++; } return $result; } }