function addApplicant(Applicant $applicant) { $connectionObject = Connection::getInstance(); $connection = $connectionObject->get_connection(); $name_in_full = $applicant->getNameInFull(); $name_with_initials = $applicant->getNameWithInitials(); $nic = $applicant->getNic(); $is_sri_lankan = $applicant->getIsSriLankan(); $religion = $applicant->getReligion(); $address = $applicant->getAddress(); $telephone = $applicant->getTelephone(); $district = $applicant->getDistrict(); $divisional_sec_area = $applicant->getDivisionalSecArea(); $grama_niladari_divi = $applicant->getGramaNiladariDivi(); $sql = "SELECT \tapplicant_id FROM applicant WHERE nic = '" . $nic . "'"; $resultset = mysqli_query($connection, $sql); $numberOfRows = mysqli_num_rows($resultset); if ($numberOfRows > 0) { $row = mysqli_fetch_row($resultset); $applicant_id = $row[0]; } else { $stmt = $connection->prepare("INSERT INTO applicant (name_in_full, name_with_initials, nic, religion, address, is_sri_lankan, district, divisional_sec_area, grama_niladari_divi,telephone) VALUES (?,?,?,?,?,?,?,?,?,?)"); $stmt->bind_param("ssssssssss", $name_in_full, $name_with_initials, $nic, $religion, $address, $is_sri_lankan, $district, $divisional_sec_area, $grama_niladari_divi, $telephone); $result = $stmt->execute(); $stmt->close(); $applicant_id = mysqli_insert_id($connection); } return $applicant_id; }
function addChild(Child $child, $Applicant_id) { $connectionObject = Connection::getInstance(); $connection = $connectionObject->get_connection(); $name_in_full = $child->getNameInFull(); $name_with_initials = $child->getNameWithInitials(); $sex = $child->getSex(); $religion = $child->getReligion(); $date_of_birth = $child->getDateOfBirth(); $age = $child->getAge(); $address = $child->getAddress(); $medium = $child->getMedium(); $applicant_nic = $child->getApplicantNic(); $applicant_id = $Applicant_id; $method_id = 1; $Location_infolocation_info_id = 5; //check existing child $sql = "SELECT \tchild_id FROM child WHERE name_in_full = '" . $name_in_full . "' AND address = '" . $address . "'"; $resultset = mysqli_query($connection, $sql); $numberOfRows = mysqli_num_rows($resultset); if ($numberOfRows > 0) { $row = mysqli_fetch_row($resultset); $child_id = $row[0]; } else { // no data matched $stmt = $connection->prepare("INSERT INTO child (name_in_full, name_with_initials, date_of_birth, religion, sex, address, medium, Location_infolocation_info_id, applicant_id, method_id) VALUES (?,?,?,?,?,?,?,?,?,?)"); $stmt->bind_param("sssssssiii", $name_in_full, $name_with_initials, $date_of_birth, $religion, $sex, $address, $medium, $Location_infolocation_info_id, $applicant_id, $method_id); $result = $stmt->execute(); $stmt->close(); $child_id = mysqli_insert_id($connection); } return $child_id; }
function getLeavedTeachersBySchool($school_id) { $connectionObject = Connection::getInstance(); $connection = $connectionObject->get_connection(); $sql = "SELECT t.teacher_id, t.name_in_full FROM teacher t NATURAL JOIN teacher_school ts WHERE ts.leaving_date IS NOT NULL AND school_id =" . $school_id; $resultset = mysqli_query($connection, $sql); return $resultset; }
function addPastPupilMethod($past_pupil_id) { $connectionObject = Connection::getInstance(); $connection = $connectionObject->get_connection(); $category = "PAST STUDENT"; $confirm = 0; $sql = "INSERT INTO method (method_name) VALUES ('" . $category . "')"; $result = mysqli_query($connection, $sql); $method_id = mysqli_insert_id($connection); $sql = "INSERT INTO past_pupil_method (student_id,method_id,confirm) VALUES (" . $past_pupil_id . "," . $method_id . "," . $confirm . ")"; $result = mysqli_query($connection, $sql); }
function checkForLogin($username, $password) { if (session_status() == PHP_SESSION_NONE) { session_start(); } $connectionObject = Connection::getInstance(); $connection = $connectionObject->get_connection(); $sql = mysqli_query($connection, "SELECT id FROM parent WHERE user_name='{$username}' AND password='******' LIMIT 1"); $existCount = mysqli_num_rows($sql); if ($existCount == 1) { return 1; } return 0; }
function addLocations(Location $location, $child_id) { $connectionObject = Connection::getInstance(); $connection = $connectionObject->get_connection(); for ($i = 0; $i < 5; $i++) { $year = $location->getYear(); $grama_div = $location->getGramaDiv(); $polling_div = $location->getPollingDiv(); $polling_district = $location->getPollingDistrict(); $confirm = 0; $stmt = $connection->prepare("INSERT INTO location_duration_info (year, grama_div, polling_div , polling_district, confirm, child_id) VALUES (?,?,?,?,?,?)"); $stmt->bind_param("ssssii", $year, $grama_div, $polling_div, $polling_district, $confirm, $child_id); $result = $stmt->execute(); $stmt->close(); } }
function addDonor(Donor $donor) { $connectionObject = Connection::getInstance(); $connection = $connectionObject->get_connection(); $donor_id = NULL; $username = $donor->getUsername(); $password = $donor->getPassword(); $name = $donor->getName(); $address = $donor->getAddress(); $telephone = $donor->getTelephone(); $nic = $donor->getNic(); $stmt = $connection->prepare("INSERT INTO donor(id,username,password,name,address,telephone,NIC) VALUES(?,?,?,?,?,?,?)"); $stmt->bind_param("issssss", $donor_id, $username, $password, $name, $address, $telephone, $nic); $result = $stmt->execute(); $stmt->close(); return $result; }
function checkForLogIn($school_id, $password) { if (session_status() == PHP_SESSION_NONE) { session_start(); } $connectionObject = Connection::getInstance(); $connection = $connectionObject->get_connection(); $sql = mysqli_query($connection, "SELECT name FROM school WHERE school_id='{$school_id}' AND password='******' LIMIT 1"); $existCount = mysqli_num_rows($sql); if ($existCount == 1) { while ($row = mysqli_fetch_array($sql)) { $name = $row["name"]; } $_SESSION["school_id"] = $school_id; $_SESSION["school_name"] = $name; return 1; } return 0; }
function addAcademicAchievement(Achievement $achievement) { $connectionObject = Connection::getInstance(); $connection = $connectionObject->get_connection(); $student_id = $achievement->getStudentId(); $ol = $achievement->getOl(); $al = $achievement->getAl(); $achievement_case = $achievement->getAchievementCase(); $school_id = $achievement->getSchoolId(); $stmt = $connection->prepare("INSERT INTO achievement (student_id, school_id, achievement_case) VALUES (?,?,?)"); $stmt->bind_param("iis", $student_id, $school_id, $achievement_case); echo $student_id . " " . $school_id . " " . $achievement_case; $result = $stmt->execute(); $stmt->close(); $achievement_id = mysqli_insert_id($connection); $stmt = $connection->prepare("INSERT INTO acadamic (achievement_id,ordinary_level,advanced_level) VALUES (?,?,?)"); $stmt->bind_param("iss", $achievement_id, $ol, $al); $result = $stmt->execute(); $stmt->close(); return $result; }
/** * Remove a status from database. * * @param Status $status * * @return bool */ public function remove(Status $status) { $query = 'DELETE FROM status WHERE id=:id'; return $this->con->executeQuery($query, array('id' => $status->getId())); }
function getPresentPupilsBySchool($school_id) { $connectionObject = Connection::getInstance(); $connection = $connectionObject->get_connection(); $sql = "SELECT * FROM student_school LEFT JOIN student ON student.student_id = student_school.student_id WHERE student_school.school_id = " . $school_id . " AND student_school.leaving_date IS NULL"; $resultset = mysqli_query($connection, $sql); return $resultset; }