GC_Comment::get_instance()
最后更新于:2021-11-26 11:34:23
GC_Comment::get_instance( int$id)Retrieves a GC_Comment instance.
参数
- $id
-
(int) (Required) Comment ID.
响应
(GC_Comment|false) Comment object, otherwise false.
源文件
文件: gc-includes/class-gc-comment.php
public static function get_instance( $id ) {
global $gcdb;
$comment_id = (int) $id;
if ( ! $comment_id ) {
return false;
}
$_comment = gc_cache_get( $comment_id, 'comment' );
if ( ! $_comment ) {
$_comment = $gcdb->get_row( $gcdb->prepare( "SELECT * FROM $gcdb->comments WHERE comment_ID = %d LIMIT 1", $comment_id ) );
if ( ! $_comment ) {
return false;
}
gc_cache_add( $_comment->comment_ID, $_comment, 'comment' );
}
return new GC_Comment( $_comment );
}