Add get_exercicesOrdered in Theme

This commit is contained in:
Li Chen 2013-11-05 03:45:48 +01:00
parent 0f18ed8dcf
commit 6baf37d4d6

View File

@ -90,9 +90,47 @@ class Theme
$array = array();
foreach ($ids as $id){
$array[] = new Theme($id['id']);
}
return $array;
}
function get_exercicesOrdered()
{
$db = new BDD();
$res = $db->query("SELECT E.id, E.require FROM exercices E
INNER JOIN themes T ON T.id = E.id_theme
WHERE T.id = ".intval($this->id));
$db->deconnexion();
$size = count($res);
for ($i = 0; $i < $size; $i++)
{
for ($j = 0; $j < $size; $i++)
{
if ($i == 0)
{
if ($res[$j]['require'] == '')
{
$tmp = $res[0];
$res[0] = $res[$j];
$res[$j] = $tmp;
}
}
else
{
if ($res[$j]['require'] == $res[$i]['id'])
{
$tmp = $res[$i];
$res[$i] = $res[$j];
$res[$j] = $tmp;
}
}
}
}
return $res;
}
}