<?php
echo ' ';
 

class indexIModel extends X {
    
    public function getModuleContentUrl($module, $id) {
        
        $url = '';
        if ($module == 'article') {
            $sql = "SELECT v.articleid,c.dirname".
                    " FROM ".DB_PREFIX."article AS v".
                    " LEFT JOIN ".DB_PREFIX."category AS c ON v.catid=c.catid".
                    " WHERE v.articleid='{$id}'";
        }
        elseif ($module == 'product') {
            $sql = "SELECT v.productid,c.dirname".
                " FROM ".DB_PREFIX."product AS v".
                " LEFT JOIN ".DB_PREFIX."category AS c ON v.catid=c.catid".
                " WHERE v.productid='{$id}'";
        }
        elseif ($module == 'photo') {
            $sql = "SELECT v.photoid,c.dirname".
                " FROM ".DB_PREFIX."photo AS v".
                " LEFT JOIN ".DB_PREFIX."category AS c ON v.catid=c.catid".
                " WHERE v.photoid='{$id}'";
        }
        elseif ($module == 'download') {
            $sql = "SELECT v.downid,c.dirname".
                " FROM ".DB_PREFIX."download AS v".
                " LEFT JOIN ".DB_PREFIX."category AS c ON v.catid=c.catid".
                " WHERE v.downid='{$id}'";
        }
        elseif ($module == 'hr') {
            $sql = "SELECT v.hrid,c.dirname".
                " FROM ".DB_PREFIX."hr AS v".
                " LEFT JOIN ".DB_PREFIX."category AS c ON v.catid=c.catid".
                " WHERE v.hrid='{$id}'";
        }
        elseif ($module == 'about') {

        }

    }
    public function getnewsid($lang){
        $sql = "SELECT catid  FROM ".DB_PREFIX."category WHERE treeid='0' AND modalias='article' AND lang='$lang'";
        $data = parent::$obj->fetch_first($sql);
        return $data['catid'];
    }
    public function getproductid($lang){
        $sql = "SELECT catid  FROM ".DB_PREFIX."category WHERE treeid='0' AND modalias='product' AND lang='$lang'";
       // echo $sql;
        $data = parent::$obj->fetch_first($sql);
        return $data['catid'];
    }    
     public function getphotoid($lang){
        $sql = "SELECT catid  FROM ".DB_PREFIX."category WHERE treeid='0' AND modalias='photo' AND lang='$lang'";
       // echo $sql;
        $data = parent::$obj->fetch_first($sql);
        return $data['catid'];
    }
    public function keyword($user_id){
        $where    = " WHERE user_id='$user_id'";
        $countsql = "SELECT COUNT(*) FROM " . DB_PREFIX . "search " . $where;
        $total    = parent::$obj->fetch_count($countsql);
        $sql      = "SELECT * FROM " . DB_PREFIX . "search " . $where ;
        $data = parent::$obj->getall($sql);
        return array($total, $data);
    }
    public function addkerword($arr){
        return parent::$obj->insert(DB_PREFIX . 'search', $arr);
    }

    public function delkeyword ($userid){
        $sql = "DELETE FROM " . DB_PREFIX . "search WHERE user_id='$userid'";
        return parent::$obj->query($sql);
    }
    public function getinfo($user_id,$keyword){
        $sql = "SELECT *  FROM ".DB_PREFIX."search WHERE user_id='$user_id' AND keyword='$keyword'";
        return parent::$obj->fetch_first($sql);
    }
}
?>
