0

不知道是我盯着这个看太久了还是怎么了。。

但是如果我使用硬编码的查询行..它可以工作。

如果我用 bindParam() 行替换那些.. 我什么也没得到?

//$calibrationDetails_sql = "SELECT equipment.*, employee.* FROM equipment, employee WHERE equipment_brand = 'Toro' AND employee_number = '1'";

$calibrationDetails_sql = "SELECT equipment.*, employee.* FROM equipment, employee WHERE equipment_brand = :equipment_number AND employee_number = :employee_number";
$calibrationDetails_stmt = $conn->prepare($calibrationDetails_sql);
$calibrationDetails_stmt->bindValue(':equipment_number', $equipment_number);
$calibrationDetails_stmt->bindValue(':employee_number', $employee_number);
$calibrationDetails_stmt->execute();
$calibrationDetails_stmt->setFetchMode(PDO::FETCH_ASSOC);   
$_calibrationDetails = $calibrationDetails_stmt->fetch(); //single row  
//$_calibrationDetails = $calibrationDetails_stmt->fetchAll(); //returns multi-dimensional array 

$colcount = $calibrationDetails_stmt->columnCount();
$rowcount = $calibrationDetails_stmt->rowCount();   
var_dump($_calibrationDetails);

if($rowcount <= 0){
    //blah blah
}else{
    //blah blah
}

如果我使用 fetch 或 fetchAll.. 我仍然没有返回任何内容.. 如果我使用 bindParam() 行.. 如果它的硬代码.. 我得到了正确返回的数据。

我也输出变量,以确保在我的查询中获得 $_POST 数据(它很好/正确)

我在这里想念什么?

4

0 回答 0