<?php
class ClassLang extends ClassConfig {
    public function __construct(){}
    public function __destruct(){}
    
    public function listLanguages($is_active='TRUE'){
        $this->_isActive = $is_active;
        $oPDOLink = ClassConfig::databaseConnect();
        $sql="
        SELECT *
        FROM core_lang;
        ";
        $execSQL = $oPDOLink->prepare($sql);
        $execSQL->execute(array());
        $rows = $execSQL->fetchAll(PDO::FETCH_ASSOC);
        return $rows;
    }
    
    public function listActiveLanguages($is_active='TRUE'){
        $this->_isActive = $is_active;
        $oPDOLink = ClassConfig::databaseConnect();
        $sql="
        SELECT *
        FROM core_lang
        WHERE is_active=".$this->_isActive.";
        ";
        $execSQL = $oPDOLink->prepare($sql);
        $execSQL->execute(array());
        $rows = $execSQL->fetchAll(PDO::FETCH_ASSOC);
        return $rows;
    }
    
    public function getLangCodeById($lang_id){
        $this->_langId = $lang_id;
        $oPDOLink = ClassConfig::databaseConnect();
        
        $sql="
        SELECT code
        FROM core_lang
        WHERE id=:lang_id;
        ";
        
        $execSQL = $oPDOLink->prepare($sql);
        $execSQL->execute(array(
            ':lang_id'=>$this->_langId
        ));
        $row = $execSQL->fetch(PDO::FETCH_ASSOC);
        return $row;
    }
}