Example #1
0
 static function dajIzvedbeKolegija($kolegij)
 {
     $baza = new BazaPlan();
     $sql = "SELECT * FROM tip_izvedbe_kolegij WHERE k_fk = {$kolegij}";
     $result = $baza->query($sql);
     $izvedba_kolegija = array();
     if ($result->num_rows > 0) {
         while ($row = $result->fetch_assoc()) {
             switch ($row['ti_fk']) {
                 case 1:
                     $izvedba_kolegija[0] = $row['tik_broj_sati'];
                     break;
                 case 2:
                     $izvedba_kolegija[1] = $row['tik_broj_sati'];
                     break;
                 case 3:
                     $izvedba_kolegija[2] = $row['tik_broj_sati'];
                     break;
                 case 4:
                     $izvedba_kolegija[3] = $row['tik_broj_sati'];
                     break;
                 default:
                     break;
             }
         }
     }
     return $izvedba_kolegija;
 }
Example #2
0
 public function connect()
 {
     // Try and connect to the database
     if (!isset(self::$connection)) {
         self::$connection = new mysqli(self::$host, self::$username, self::$password, self::$database);
         self::$connection->set_charset('utf8');
     }
     // If connection was not successful, handle the error
     if (self::$connection === false) {
         // Handle error - notify administrator, log to a file, show an error screen, etc.
         echo 'Cannot connect to database.';
         return false;
     }
     return self::$connection;
 }