Skip to content

Instantly share code, notes, and snippets.

@diparthshah
Last active January 13, 2020 17:29
Show Gist options
  • Save diparthshah/537b2e808f3c1a41081941e7c9c54ada to your computer and use it in GitHub Desktop.
Save diparthshah/537b2e808f3c1a41081941e7c9c54ada to your computer and use it in GitHub Desktop.
GodSpeed Algorithm: Request scheduling and allocation algorithm for relational database platform designed and developed by Team Pakodanomics.
/* GodSpeed Algorithm */
<?php
class Scheduler {
var $servername = "localhost";
var $username = "root";
var $password = "";
var $dbname = "project101";
var $array = array();
function getEmployeeTable($group) {
$conn = mysqli_connect($this->servername, $this->username, $this->password, $this->dbname);
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
$sql = "SELECT * FROM deptdb WHERE groupid = '$group' " ;
if ($res = mysqli_query($conn, $sql)) {
if (mysqli_num_rows($res) > 0) {
$idx = -1;
while ($row = mysqli_fetch_assoc($res)) {
$idx = $idx + 1;
$this->array[$idx] = $row;
}
}
}
}
function getCandidateEmployee() {
$a = $this->array;
$n = count($a);
for ($i = 0; $i < $n - 1; $i++) {
for ($j = 0; $j < $n - $i - 1; $j++) {
if ($a[$j]['curassigned'] > $a[$j + 1]['curassigned'] && $a[$j]['totalcompleted'] >= $a[$j + 1]['totalcompleted'] ||
$a[$j]['curassigned'] < $a[$j + 1]['curassigned'] && $a[$j]['totalcompleted'] > $a[$j + 1]['totalcompleted'] ||
$a[$j]['curassigned'] == $a[$j + 1]['curassigned'] && $a[$j]['totalcompleted'] > $a[$j + 1]['totalcompleted']) {
$temp = $a[$j];
$a[$j] = $a[$j + 1];
$a[$j + 1] = $temp;
}
}
}
return $a[0]['eid'];
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment