0
有沒有在PDOStatement::execute
中指定PDO::PARAM_INT
的方法?PDO :: PARAM_INT在PDOStatement ::執行
我習慣做如下結果:
$STH = $DBH->prepare('INSERT INTO items (name, description) VALUES (:name, :description)');
$STH->execute(array(':name' => $name, ':description' => $description));
但是,已經被插入的值必須是整數的時候..
據我所知,人們可以使用bindValue
或bindParam
..
$STH->bindParam(':price', $price, PDO::PARAM_INT);
不過,我想是這樣的:
$STH->execute(array(':price' => array('value' => $price, 'type' => PDO::PARAM_INT)));
這是否存在?
['PDOStatement :: execute()'](http://php.net/manual/en/pdostatement.execute.php)只需要一個參數 - 一個$ input_parameters數組,因此您需要使用'bind *'函數明確。 –
爲什麼不在驗證過程中確保它是一個整數? – brianforan
手冊中有一些示例僅針對您所問的問題,您有沒有看過/嘗試過? –