Comments not enabled for custom post types

WordPress, by default don’t enable comments on custom post types, and once you have added support for comments, you still get the following message: Comments are closed

You have to basically manually visit each custom post and enable comments in the post editor screen.

There are however a workaround to enable comments by default in bulk. You can use the following snippet to enable comments in bulk

function switch_on_comments_automatically(){
    global $wpdb;
    $wpdb->query( $wpdb->prepare("UPDATE $wpdb->posts SET comment_status="open"")); // Switch comments on automatically
} 

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)