public function set_assoc_array(array $arr, $id_present = false)
 {
     // Initialize Success Variable
     $suc = parent::set_assoc_array($arr, $id_present);
     foreach ($this as $key => $val) {
         $suc[$key] = false;
     }
     $suc['lec_id'] = true;
     // Trim Values
     array_walk($arr, array($this, 'trim_value'));
     // Is ID Present
     if ($id_present && isset($arr['lec_id']) && ctype_digit($arr['lec_id'])) {
         $this->lec_id = $arr['lec_id'];
     }
     // Validation
     if (isset($arr['lec_date']) && !empty($arr['lec_date'])) {
         try {
             $st = new DateTime($arr['lec_date']);
             $this->lec_date = $st->format("Y-m-d");
             $suc['lec_date'] = true;
         } catch (Exception $e) {
         }
     }
     if (isset($arr['attd_mst_id']) && ctype_digit($arr['attd_mst_id'])) {
         $this->attd_mst_id = $arr['attd_mst_id'];
         $suc['attd_mst_id'] = true;
     }
     return $suc;
 }
<?php

// Check not accessed directly.
if (!isset($post_add)) {
    echo "Are you searching for something? You maybe in wrong place then!!";
    return;
}
$obj = new Attendance_Master();
$suc = $obj->set_assoc_array($_POST);
if (Master::isLegit($suc)) {
    $_POST['syllabus_id'] = MyHttpRequest::insertAndGetId("Syllabus", "syllabus_id", $_POST);
    $_POST['teaches_id'] = MyHttpRequest::insertAndGetId("Teaches", "teaches_id", $_POST);
    require_once "./common.php";
} else {
    echo json_encode($suc);
}