Add get_exercicesOrdered in Theme
This commit is contained in:
parent
0f18ed8dcf
commit
6baf37d4d6
1 changed files with 39 additions and 1 deletions
|
@ -90,9 +90,47 @@ class Theme
|
||||||
$array = array();
|
$array = array();
|
||||||
foreach ($ids as $id){
|
foreach ($ids as $id){
|
||||||
$array[] = new Theme($id['id']);
|
$array[] = new Theme($id['id']);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $array;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue