Exercice.class: fixed the id type

This commit is contained in:
Li Chen 2013-10-26 20:54:15 +02:00
parent d2580d2026
commit d2060ce1b8

View file

@ -1,5 +1,7 @@
<?php
//TODO: get the exercice number
if(!defined('ONYX')) exit;
class Exercice
@ -18,13 +20,14 @@ class Exercice
if (!empty($id))
{
$db = new BDD();
// TODO escape id ?
$res = $db->unique_query("SELECT `id`, `id_theme`, `require`, `level`, `points`, `statement`
FROM exercices
WHERE id=" . intval($id));
WHERE id= '$id'");
if (!empty($res))
{
$this->id = intval($res['id']);
$this->id = $res['id'];
$this->theme = new Theme($res['id_theme']);
$this->require = $res['require'];
$this->level = $res['level'];
@ -32,10 +35,10 @@ class Exercice
$this->statement = $res['statement'];
$this->files = $db->query("SELECT `id`, `path`, `name`
FROM exercice_files
WHERE id_exercice = $id");
WHERE id_exercice = '$id'");
$this->keys = $db->query("SELECT `id`, `format`, `value`
FROM exercice_keys
WHERE id_exercice = $id");
WHERE id_exercice = '$id'");
}
$db->deconnexion();
}
@ -67,7 +70,7 @@ class Exercice
{
$db->query("UPDATE exercices
SET `theme` = '".$theme."', `require` = '".$require."', `level` = '".$level."', `point` = '".$point."', `statement` = '".$statement."'
WHERE id = ".$id);
WHERE id = '$id'");
$aff = $db->affected();
}