public static function insertAndGetId($class, $keycol, array $postData = array()) { $obj = new $class(); $suc = $obj->set_assoc_array($postData); if (Master::isLegit($suc)) { $where = $obj->get_assoc_array(); unset($where[$keycol]); $clms = array("CLM5" => $keycol); $params = array_merge($where, $clms); $data = null; MyHttpRequest::postTableData($data, "?master={$class}", $postData); //print_r($data); MyHttpRequest::getJSONTableData($data, "?master={$class}", $params); //print_r($data); return $data[0][$keycol]; } return false; }
<?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); }