Title: Where is the comments SQL?
Last modified: August 19, 2016

---

# Where is the comments SQL?

 *  Resolved [t3ch33](https://wordpress.org/support/users/t3ch33/)
 * (@t3ch33)
 * [18 years, 3 months ago](https://wordpress.org/support/topic/where-is-the-comments-sql/)
 * Where is the comments SQL located?

Viewing 3 replies - 1 through 3 (of 3 total)

 *  [moshu](https://wordpress.org/support/users/moshu/)
 * (@moshu)
 * [18 years, 3 months ago](https://wordpress.org/support/topic/where-is-the-comments-sql/#post-702559)
 * You may want to re-phrase it because it doesn’t make sense in its present form…
 *  [whooami](https://wordpress.org/support/users/whooami/)
 * (@whooami)
 * [18 years, 3 months ago](https://wordpress.org/support/topic/where-is-the-comments-sql/#post-702562)
 * related to this, im guessing:
 * [http://wordpress.org/support/topic/158637?replies=3](http://wordpress.org/support/topic/158637?replies=3)
 * you want to know where the sql is that inserts the comment?
 * inside wp-includes/comment.php :
 *     ```
       function wp_insert_comment($commentdata) {
       	global $wpdb;
       	extract($commentdata, EXTR_SKIP);
       	if ( ! isset($comment_author_IP) )
       		$comment_author_IP = preg_replace( '/[^0-9., ]/', '',$_SERVER['REMOTE_ADDR'] );
       	if ( ! isset($comment_date) )
       		$comment_date = current_time('mysql');
       	if ( ! isset($comment_date_gmt) )
       		$comment_date_gmt = get_gmt_from_date($comment_date);
       	if ( ! isset($comment_parent) )
       		$comment_parent = 0;
       	if ( ! isset($comment_approved) )
       		$comment_approved = 1;
       	if ( ! isset($user_id) )
       		$user_id = 0;
       	$result = $wpdb->query("INSERT INTO $wpdb->comments
       	(comment_post_ID, comment_author, comment_author_email, comment_author_url, comment_author_IP, comment_date, comment_date_gmt, comment_content, comment_approved, comment_agent, comment_type, comment_parent, user_id)
       	VALUES
       	('$comment_post_ID', '$comment_author', '$comment_author_email', '$comment_author_url', '$comment_author_IP', '$comment_date', '$comment_date_gmt', '$comment_content', '$comment_approved', '$comment_agent', '$comment_type', '$comment_parent', '$user_id')
       	");
       	$id = (int) $wpdb->insert_id;
       	if ( $comment_approved == 1)
       		wp_update_comment_count($comment_post_ID);
       	return $id;}
       ```
   
 *  Thread Starter [t3ch33](https://wordpress.org/support/users/t3ch33/)
 * (@t3ch33)
 * [18 years, 3 months ago](https://wordpress.org/support/topic/where-is-the-comments-sql/#post-702571)
 * I found what I was looking for in wp-includes/comment-template.php, but that 
   is helpful, too. Thanks.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Where is the comments SQL?’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 3 replies
 * 3 participants
 * Last reply from: [t3ch33](https://wordpress.org/support/users/t3ch33/)
 * Last activity: [18 years, 3 months ago](https://wordpress.org/support/topic/where-is-the-comments-sql/#post-702571)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
