In general, I have been working with PDO recently and have already failed to understand how the error is:
$stmt = $pdo->prepare("(SELECT COUNT(goods_id) as count_rows FROM goods WHERE goods_brandid = :category AND visible='1') UNION (SELECT COUNT(goods_id) as count_rows FROM goods WHERE goods_brandid IN (SELECT brand_id FROM brands WHERE parent_id = :category) AND visible='1')"); $stmt->execute(array("category" => $category)); while($row = $stmt->fetch(PDO::FETCH_ASSOC)){ if($row['count_rows']) $count_rows = $row['count_rows']; } return $count_rows; And here is the error:
Fatal error: Uncaught PDOException: SQLSTATE[HY093]: Invalid parameter number in D:\OpenServer\domains\InterMag.ru\model\model.php:138 Stack trace: #0 D:\OpenServer\domains\InterMag.ru\model\model.php(138): PDOStatement->execute(Array) #1 D:\OpenServer\domains\InterMag.ru\controller\controller.php(140): count_rows(Object(PDO), 5) #2 D:\OpenServer\domains\InterMag.ru\index.php(10): require_once('D:\\OpenServer\\d...') #3 {main} thrown in D:\OpenServer\domains\InterMag.ru\model\model.php on line 138 Tell me where is the error ??
:category. See php.net/manual/ru/pdo.prepare.php - Akina