<?php
require_once(LIB_PATH . DS . 'database.php');

class Academics extends DatabaseObject
{
    protected static $table_name = "subjects";
    public $id;
    public $acc_id;
    public $sitting;
    public $examno;
    public $examno2;

    public $examyear;

    public $examyear2;
    public $sub1;

    public $sub2;
    public $sub3;
    public $sub4;
    public $sub5;
    
    
    public $jregno;
    public $jscore;
    

    public $institution;

    public $grag;
    public $gragD;
    public $name;
    public $grd;
    
    public $comp;
    public $dstart;
    public $dcomp;
   
    
    
    

   

    public static function Cform($id=''){

    global $database; 
    $id = $database->escape_value($id);

      $sql = "SELECT * FROM academics_data ";
         
      $sql .= " WHERE acc_id='{$id}' limit 1 ";
 
         
       return $result_array = self::find_by_sql($sql);

   }
    
public static function grd_retriever(){
        global $database;
        //$lev = $database->escape_value($lev);

        $sql = "SELECT * FROM grades order by grd ";
         
 
         
       return $result_array = self::find_by_sql($sql);
        //return !empty($result_array) ? array_shift($result_array) : false;
//return $result_array;
  


    }


Public static function sub_retriever(){
        global $database;
        //$lev = $database->escape_value($lev);

        $sql = "SELECT * FROM subjects order by name ";
         
 
         
       return $result_array = self::find_by_sql($sql);
        //return !empty($result_array) ? array_shift($result_array) : false;
//return $result_array;
  


    }



        public static function insertAcademics($stdid='', $sitting='', $examno='', $examno2='', $examname='', $examname2='',$examyear='',
        $examyear2='', $sgrade1='', $sgrade2='', $sgrade3, $sgrade4, $sgrade5,$jregno='', $jscore='',$instC='',$inst='',$grag='',$gragD='',$itcompany='',$dstarted='',$dcompleted=''){

        global $database;$connection='';

        $stdid = $database->escape_value($stdid);
        $sitting = $database->escape_value($sitting);
        
        $examno = $database->escape_value($examno);
        $examno2 = $database->escape_value($examno2);

        $examyear = $database->escape_value($examyear);
        $examyear2 = $database->escape_value($examyear2);

        $sgrade1 = $database->escape_value($sgrade1);
        $sgrade2 = $database->escape_value($sgrade2);

       $sgrade3 = $database->escape_value($sgrade3);
       $sgrade4 = $database->escape_value($sgrade4);

       $sgrade5 = $database->escape_value($sgrade5);
       
       $jregno = $database->escape_value($jregno);
       $jscore = $database->escape_value($jscore);

       $instC = $database->escape_value($instC);

        $inst = $database->escape_value($inst);
      
        $grag = $database->escape_value($grag);
        $gragD = $database->escape_value($gragD);
      
       $itcompany = $database->escape_value($itcompany);
      
        $dstarted = $database->escape_value($dstarted);
        $dcompleted = $database->escape_value($dcompleted);
      
       $sql = "INSERT INTO academics_data (";
        $sql .= "acc_id,sitting,examno,examno2, examyear, examyear2, sub1, sub2, sub3, sub4, sub5,jregno,jscore,jinstitution,institution,grag,gragD,itcompany,dstarted,dcompleted ";

        $sql .= ") VALUES ('";
        $sql .= $stdid . "', '";
        $sql .= $sitting . "', '";
        $sql .= $examno . "', '";
        $sql .= $examno2 . "', '";
        $sql .= $examyear . "', '";
        $sql .= $examyear2 . "', '";

        $sql .= $sgrade1 . "', '";
        $sql .= $sgrade2 . "', '";
        $sql .= $sgrade3 . "', '";

        $sql .= $sgrade4 . "', '";

        $sql .= $sgrade5 . "', '";
        
         $sql .= $jregno . "', '";

        $sql .= $jscore . "', '";

        $sql .= $instC . "', '";
        
        
        $sql .= $inst . "', '";

        $sql .= $grag . "', '";
        $sql .= $gragD . "', '";
        
         $sql .= $itcompany . "', '";

        $sql .= $dstarted . "', '";
        $sql .= $dcompleted . "'
              
            )";

        if ($database->query($connection,$sql)) {
            //$this->id=$database->insert_id();
            return true;
          // return 'Success';
        } else {
           return false;
            // return 'Error'; 
        }
    }




   
//Common database Methods

}
 $academics = new Academics();
?>