<?php
/**
 * User: David Camacho
 * Date: 31/03/2015
 * Time: 19:01
 */



class Module extends DataBaseController
{

    public function Module()
    {
        parent::DataBaseController();

    }

    public function getStudentModulesNames()
    {

        $res = array();
        $sql = "SELECT name
				FROM " . _db_prefix . "_module
				WHERE active = 1
				AND role = 0
				ORDER BY order_num ASC
				";
        if (isset($this->db)) {
            $tmp = $this->db->prepare($sql);
            $tmp->execute();
            $tmp->bind_result($result);
            while ($tmp->fetch()) {
                array_push($res,$result);
            }
            $tmp->close();
            return $res;
        }
    }

    public function getTeacherModulesNames()
    {

        $res = array();
        $sql = "SELECT name
				FROM " . _db_prefix . "_module
				WHERE active = 1
				AND role = 1
				ORDER BY order_num ASC
				";
        if (isset($this->db)) {
            $tmp = $this->db->prepare($sql);
            $tmp->execute();
            $tmp->bind_result($result);
            while ($tmp->fetch()) {
                array_push($res,$result);
            }
            $tmp->close();
            return $res;
        }
    }

    public function destroy(){
        // close the mysqli connection
        $this->db->close();

    }

}