我尝试在FormulaireModel.php中运行此功能,我遇到了此错误,我使用MVC PHP。预先感谢您的回答
public function getUnic( $id ){
try{
if($q = $this->_db->prepare('SELECT * FROM `imp_operations_fact` WHERE `ID`=:id')!=false){
if($q->bindParam(':id', $id) && $q->execute()){
$result = $q->fecth(PDO::FETCH_ASSOC);
}return $result;
}return false;
}catch (PDOException $e){
die($e->getMessage());
}
}
致命错误:未捕获的错误:调用成员函数bindParam()布尔在C:\ xampp \ htdocs \ ORP_PHP \ App \ Models \ FormulaireModel.php:40堆栈跟踪:#0C:\ xampp \ htdocs \ ORP_PHP \ App \ Controllers \ FormulaireController.php(78):FormulaireModel-> getUnic('18')#1C:\ xampp \ htdocs \ ORP_PHP \ FW \ core \ CoreController.php(153):FormulaireController-> editerAction()#2C:\ xampp \ htdocs \ ORP_PHP \ index.php(34):CoreController-> launcher('editerAction')#3 {main}被抛出C:\ xampp \ htdocs \ ORP_PHP \ App \ Models \ FormulaireModel.php,第40行
try{
if($q = $this->_db->prepare('SELECT * FROM `imp_operations_fact` WHERE `ID`=:id')){
if($q->bindParam(':id', $id) && $q->execute()){
$result = $q->fetch(PDO::FETCH_ASSOC);
}return $result;
}return false;
}catch (PDOException $e){
die($e->getMessage());
}
}
随后检查函数是否返回true或false。