I'm having trouble updating a mysql database using PDO. I am not getting any error message when I execute the update query but it's not updating that database. Error reporting is on i think - self::$db->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION ) - and i did get an error at the start indicating i had got a column name wrong and one about a syntax error but since fixing those I'm not getting any error messages. I've tried various things from some of the other similar queries without joy.
I have a class called Events, the constructor executes a select statement without problem. Update is a function in the class and the $array parameter being passed in is $_POST (submitted form data) - am I trying to access this $_POST data from $array the wrong way?
here is the function
function update ($array) {
$this->db = mydb::getConnection();
try {
// prepare statement
$statement = $this->db->prepare("UPDATE gigs SET who = :who WHERE gig_id = :gig_id");
// bind parameters
$statement->bindParam(':gig_id', $array['gig_id'], PDO::PARAM_INT);
$statement->bindParam(':who', $array['who'], PDO::PARAM_STR);
// execute statement
$statement->execute();
} catch (Exception $ex) {
throw $ex;
}
}
Thanks for any suggestions.
catchblock, tryecho $ex->getMessage()to see if there's an error. - Rob W$arraykeys exist and have values? Tryvar_dump($array)- Rob WPDOExceptionjust as a trial. - Rob W