我无法理解这里的\\uu构造的功能。我知道在任何类中,只要类被实例化,\\uu构造就会运行。然而,我好奇的是,当$marks在\\uu construct函数中定义为null时,为什么它要在\\uu construct的if语句中检查其值?它不会总是返回false吗?
class Marks_Manage
{
public $mark_id;
public $exam_id;
public $class_id;
public $subject_id;
public $marks;
public $attendance;
public $student_id;
public $marks_comment;
public $created_date;
//current_time( \'mysql\' );
public function __construct( $marks = null )
{
if($marks)
{
global $wpdb;
$table_name = $wpdb->prefix . "marks";
$mark_data = $wpdb->get_row( "SELECT * FROM $table_name WHERE mark_id=".$marks);
$this->mark_id = $mark_data->mark_id;
$this->exam_id = $mark_data->exam_id;
$this->class_id = $mark_data->class_id;
$this->subject_id = $mark_data->subject_id;
$this->marks = $mark_data->marks;
$this->attendance = $mark_data->attendance;
$this->student_id = $mark_data->student_id;
$this->marks_comment = $mark_data->marks_comment;
}
}