<code lang="php">
public static function addProducts($user_id)
{
$user_id = intval($user_id);
if (isset($_SESSION['user'])) {
$user_id = $_SESSION['user'];
$db = Db::getConnection();
$sql = "UPDATE cart
SET user_id = :user_id";
$result = $db->prepare($sql);
$result->bindParam(':user_id', $user_id, PDO::PARAM_STR);
return $result->execute();
}
}
</code>