使用PDO调用布尔错误的成员函数bind_param()

时间:2016-01-14 15:50:46

标签: php pdo prepared-statement

我正在尝试使用PDO尝试执行UPDATE查询的函数,当我运行以下错误消息时,任何人都可以建议出错:?

  

在...第89行的布尔值中调用成员函数bind_param()

我的代码: -

public function updateForecast($UID, $lat, lng) {
    $forecast = new Forecast('xxxxxxxxxxxxxxxxxxxxxx');

    $hub_forecast = $forecast->get($lat,$lng);
    $current_forecast = (is_object($hub_forecast) && isset($hub_forecast->currently)) ? $hub_forecast->currently : NULL;

    $temperature = (is_object($current_forecast) && isset($current_forecast->temperature)) ? ($current_forecast->temperature - 32) / 1.8 : '';
    $precipitation = (is_object($current_forecast) && isset($current_forecast->precipProbability)) ? $current_forecast->precipProbability : '';
    $humidity = (is_object($current_forecast) && isset($current_forecast->humidity)) ? ($current_forecast->precipProbability * 100) : '';
    $status = (is_object($current_forecast) && isset($current_forecast->summary)) ? $current_forecast->summary : '';
    $temperature_feels = (is_object($current_forecast) && isset($current_forecast->apparentTemperature)) ? ($current_forecast->apparentTemperature - 32) / 1.8: '';

    $sql = "UPDATE weather_data SET
        temperature = ?,
        precipitation= ?,
        humidity = ?,
        status = ?,
        temperature_feels = ?
        WHERE UID = ?";
    $stmt = $this->db->prepare($sql);
    $stmt->bind_param('ssssss', $UID, $temperature, $precipitation, $humidity, $status, $temperature_feels); // line 89
    $stmt->execute();
    $this->db->commit();
    $stmt->close();
}

//使用lat / lng值运行查询(第一个参数是内部唯一标识符)

 updateForecast('12356','52.490074299999996','-1.9119724');

0 个答案:

没有答案