When to call mysqli::close

From: Date: Tue, 31 Jan 2012 16:28:49 +0000
Subject: When to call mysqli::close
Groups: php.general 
Request: Send a blank email to php-general+get-316437@lists.php.net to get a copy of this message
Hi good people, When should i call mysqli::close ? Should I call $stmt->close() at the end of the method(below) . Or should I call it after every condition ensuring that I close the database connection even if the process fails at some stage e.g bind param public function function_name($id,$new_id ){ $query = "UPDATE TABLE SET name = ? WHERE field = ? "; if($stmt=$this->prepare($query)){ if($stmt->bind_param("is", $id, $new_id)){ if($stmt->execute()){ }else{//Could not execute the prepared statement $message = "Could not execute the prepared statement"; } }else{//Could not bind the parameters $message = "Could not bind the parameters"; } }else{ $message = "Could not prepare the statement"; } return $message } Kind regards Albert Kamau -------------------------------------------------------------------- Saf : 0720550742

« previous php.general (#316437) next »