これで、頭がおかしくなるようなPDOExceptionが発生しました。ここで生成された例外は次のとおりです。PDOException:SQLSTATE [IMSSP]:パラメーター番号65536をバインドしようとしました。SQL Serverは最大2100個のパラメーターをサポートしています。
PDOException: SQLSTATE[IMSSP]: Tried to bind parameter number 65536. SQL Server supports a maximum of 2100 parameters. in D:\Work\CEUR16-004\Project\www_root\includes\scripts\php\libCore\products.php:169
Stack trace:
#0 D:\Work\CEUR16-004\Project\www_root\includes\scripts\php\libCore\products.php(169): PDOStatement->execute()
#1 D:\Work\CEUR16-004\Project\www_root\includes\pages\products\products.php(5): ProductCore->build_product_list()
#2 D:\Work\CEUR16-004\Project\www_root\index.php(27): include('D:\\Work\\CEUR16-...')
#3 {main}
そして、ここではそれが参照するコードさ:$this->product_type_id
は999
に等しいとき
public function build_product_list()
{
// This function builds the product list visible on the main site (guests only)
try
{
if($this->product_type_id == "999")
{
$query = 'SELECT sp.product_id, sp.product_name, sp.product_price, pt.product_type_name FROM shop_products AS sp LEFT JOIN product_types AS pt ON sp.product_type_id = pt.product_type_id ORDER BY sp.product_type_id ASC'; // Line 161
}
else
{
$query = 'SELECT sp.product_id, sp.product_name, sp.product_price, pt.product_type_name FROM shop_products AS sp LEFT JOIN product_types AS pt ON sp.product_type_id = pt.product_type_id WHERE sp.product_type_id = :product_type_id ORDER BY sp.product_id ASC';
}
$stmt = $this->dbcore_prod_core->dbc->prepare($query);
$stmt->bindParam(':product_type_id', $this->product_type_id, PDO::PARAM_INT);
$stmt->execute(); // Line 169
// Function continues below...
は今、この例外がのみ生成されるライン161上のクエリを実行します(上記のコードで注釈が付けられています)。私はサーバ上で直接クエリを実行し、期待される結果を返します。なぜPDOが例外をスローしますか?