I've added database structure at the bottom
I have a ranking system in the making for a recruitment agency.. I capture all applicants details in different tables, and to rank them (if they fit the needs/requirements of a certain job advert) by comparing the data of the candidates that is in the database to the job in the job_advert table. And then display a list of the 10 best ranking (qualified) candidates would be sent a notification that they qualify for the job.
I get the candidates data from the database like so:
class ranking_model extends CI_Model {
function __construct() {
parent::__construct();
}
function age() {
$sql = "SELECT * FROM membership";
$query = $this->db->query($sql)->result();
foreach ($query as $row) {
$id = $row->id_number;
$dobs = substr($id, 0, 6);
$dob = str_split($dobs, 2);
$day = date('d', mktime(0, 0, 0, 0, $dob[2], 0));
$month = date('m', mktime(0, 0, 0, $dob[1] + 1, 0, 0));
$year = date('o', mktime(0, 0, 0, 0, 0, $dob[0] + 1));
$date = "$day/$month/$year";
//explode the date to get month, day and year
$date = explode("/", $date);
//get age from date or birthdate
$age = (date("md", date("U", mktime(0, 0, 0, $date[0], $date[1], $date[2]))) > date("md") ? ((date("Y") - $date[2]) - 1) : (date("Y") - $date[2]));
}
return $age;
}
function job_experience() {
$sql = "SELECT * FROM job_list
JOIN job_history
ON job_list.job_history_id = job_history.job_history_id";
$query = $this->db->query($sql)->result();
foreach ($query as $row) {
$start = $row->start_date;
$end = $row->end_date;
// //explode the date to get month, day and year
$start = explode("-", $start);
$end = explode("-", $end);
// //get age from date or birthdate
$exp_in_years = (date("md", date("U", mktime(0, 0, 0, $start[2], $start[1], $start[0]))) > date("md", mktime(0, 0, 0, $end[2], $end[1], 0)) ? ((date("Y", mktime(0, 0, 0, 0, 0, $end[0])) - $start[0])) : (date("Y", mktime(0, 0, 0, 0, 0, $end[0])) - $start[0]));
}
return $exp_in_years;
}
function location() {
$sql = "SELECT * FROM personal";
$query = $this->db->query($sql)->result();
foreach ($query as $row) {
$city = $row->city;
}
return $city;
}
function relocate() {
$sql = "SELECT * FROM personal";
$query = $this->db->query($sql)->result();
foreach ($query as $row) {
$relocate = $row->relocate; //are you willing to relocate yes/no
}
return $relocate;
}
function get_personal() {
$this->db->select('*');
$this->db->from('membership');
$this->db->join('personal', 'membership.id_number = personal.id_number');
$query = $this->db->get()->result();
foreach ($query as $row) {
$row->id_number;
$row->firstname;
}
return $query;
}
and the advert details like this:
function get_advert() {
$sql = "SELECT * FROM job_advert";
$query = $this->db->query($sql)->result();
foreach ($query as $row) {
$job_id = $row->job_id;
$job_title = $row->job_title;
$salary_offered = $row->salary_offered;
$is_negotiable = $row->negotiable;
$company_location = $row->company_location;
$experience = $row->required_experience;
$age = $row->age;
}
}
}
now I don't know how to compare the candidates data with the data that I get from the job_adverts table. I really have no idea. Help of any sort would be appreciated.
Database structure
bold PK itacic is FK.
membership(id_number, firstname, lastname, username, email, phone, password, role, Reg_time, activated);
personal(person_id, address, city, licence, id_number, gender, relocate, minimum_salary, prefered_salary, contract_type);
job_list(job_list_id, job_history_id, start_date, end_date, income, company_name, industry_type, reason_for_leaving, job_title);
job_history(job_history_id, id_number);
job_advert(advert_id, job_title, job_description, start_date, end_date, salary_offered, negotiable, benefits, company_location, required_experience, age);
I have more tables in the db, but these are the ones I use for ranking.