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