GWibisono

kagak bisa load view

Aug 3rd, 2013
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.81 KB | None | 0 0
  1. <?php
  2. /* CONTROLLER */
  3. class Home extends CI_Controller {
  4.  
  5.     function __construct()
  6.     {
  7.         parent::__construct();
  8.         $this->load->database();
  9.  
  10.     }
  11.     function index()
  12.     {
  13.         $sql = $this->db->query("select * from fc_users");
  14.         $d = $sql->result_array();
  15.         print_r($d);
  16.         $body["meta_title"] = $this->Ca_get->getSetting('meta','sentence');
  17.         $body["meta_description"] = $this->Ca_get->getSetting('meta','sentence2');
  18.         $body["meta_keywords"] = $this->Ca_get->getSetting('meta','sentence3');
  19.         $body["meta_author"] = $this->Ca_get->namesite();
  20.         $this->load->view("frontend/".$this->Ca_get->name_template()."/view/containerview-home",$body);
  21.     }
  22.  
  23. }
  24. ?>
  25. <!-- MODEL -->
  26. <?php
  27. class Ca_get extends CI_Model {
  28.  
  29.     function __construct()
  30.     {
  31.         parent::__construct();
  32.         $this->load->database();
  33.         $this->load->library('session');
  34.     }
  35.  
  36.     //Value
  37.     function getValue($table, $field, $where)
  38.     {
  39.         $query = $this->db->query("SELECT $field FROM $table $where");
  40.         if ($query->num_rows() > 0) {
  41.         $hasil = $query->row();
  42.         //print_r($hasil);
  43.         return $hasil->$field;
  44.         } else return FALSE;
  45.     }
  46.    
  47.     function getArray($select,$table,$where,$out){
  48.         $q = mysql_query("select $select from $table where $where");
  49.         $data = array();
  50.         while($f = mysql_fetch_array($q))
  51.         {
  52.             $data[] = $f[$out];
  53.         }
  54.         $output = implode(",",$data);
  55.         echo $output;
  56.     }
  57.  
  58.     //Count
  59.     function getCount($table, $where="")
  60.     {
  61.         if($where != ""){
  62.             $query = $this->db->query("SELECT count(*) as count FROM $table where $where");
  63.         }else if($where == ""){
  64.             $query = $this->db->query("SELECT count(*) as count FROM $table");
  65.         }
  66.         if ($query->num_rows() > 0) {
  67.             $hasil = $query->row();
  68.         //print_r($hasil);
  69.             return $hasil->count;
  70.         } else return FALSE;
  71.     }
  72.     //Author
  73.    
  74.     function getAuthor($id=0)
  75.     {
  76.         if ($id == 0) return FALSE;
  77.         $query = $this->db->query("SELECT * FROM fc_users WHERE users_id='$id'");
  78.         if ($query->num_rows() > 0) {
  79.             $hasil = $query->row();
  80.             $name = $hasil->name;
  81.             $ext = explode(" ", $name);
  82.             return $ext[0];
  83.         } else return FALSE;
  84.     }
  85.    
  86.     function getEmailauthor($id=0)
  87.     {
  88.         if ($id == 0) return FALSE;
  89.         $query = $this->db->query("SELECT * FROM fc_users WHERE users_id='$id'");
  90.         if ($query->num_rows() > 0) {
  91.             $hasil = $query->row();
  92.             return $hasil->email;
  93.         } else return FALSE;
  94.     }
  95.    
  96.     function getImageauthor($id=0)
  97.     {
  98.         if ($id == 0) return FALSE;
  99.         $query = $this->db->query("SELECT * FROM fc_users WHERE users_id='$id'");
  100.         if ($query->num_rows() > 0) {
  101.             $hasil = $query->row();
  102.             return $hasil->img_url;
  103.         } else return FALSE;
  104.     }
  105.    
  106.     function getPost($id=0,$object)
  107.     {
  108.         if ($id == 0) return FALSE;
  109.         $query = $this->db->query("SELECT * FROM fc_post WHERE post_id='$id'");
  110.         if ($query->num_rows() > 0) {
  111.             $hasil = $query->row();
  112.             return $hasil->$object;
  113.         } else return FALSE;
  114.     }
  115.    
  116.     function getUsers($id=0,$object)
  117.     {
  118.         if ($id == 0) return FALSE;
  119.             $query = $this->db->query("SELECT * FROM fc_users WHERE users_id='$id'");
  120.         if ($query->num_rows() > 0) {
  121.             $hasil = $query->row();
  122.             return $hasil->$object;
  123.         } else return FALSE;
  124.     }
  125.    
  126.     function getSetting($cat="",$object="")
  127.     {
  128.         if ($cat == "") return FALSE;
  129.         $query = $this->db->query("SELECT * FROM fc_setting WHERE category = '$cat'");
  130.         if ($query->num_rows() > 0) {
  131.             $hasil = $query->row();
  132.             return $hasil->$object;
  133.         } else return FALSE;
  134.     }
  135.     //Email
  136.     function emailsite()
  137.     {
  138.         $q = $this->db->query("select * from fc_company_profile");
  139.         $q = $q->result_array();
  140.         foreach ($q as $row){
  141.             $output = $row["email"];
  142.         }  
  143.         return $output;
  144.  
  145.     }
  146.     //Map
  147.     function mapsite()
  148.     {
  149.         $q = $this->db->query("select * from fc_company_profile");
  150.         $q = $q->result_array();
  151.         foreach ($q as $row){
  152.             $output = $row["map_location"];
  153.         }
  154.     return $output;
  155.  
  156.     }
  157.     //Name Site
  158.     function namesite()
  159.     {
  160.         $q = $this->db->query("select * from fc_company_profile");
  161.         $q = $q->result_array();
  162.         foreach ($q as $row){
  163.             $output = $row["name"];
  164.         }
  165.     return $output;
  166.  
  167.     }
  168.     function phone()
  169.     {
  170.         $q = $this->db->query("select * from fc_company_profile");
  171.         $q = $q->result_array();
  172.         foreach ($q as $row){
  173.             $output = $row["phone"];
  174.         }
  175.     return $output;
  176.  
  177.     }
  178.     function address()
  179.     {
  180.         $q = $this->db->query("select * from fc_company_profile");
  181.         $q = $q->result_array();
  182.         foreach ($q as $row){
  183.             $output = $row["address"];
  184.         }
  185.     return $output;
  186.  
  187.     }
  188.     function profile()
  189.     {
  190.         $q = $this->db->query("select * from fc_company_profile");
  191.         $q = $q->result_array();
  192.         foreach ($q as $row){
  193.             $output = $row["profile"];
  194.         }
  195.     return $output;
  196.  
  197.     }
  198.     function name_template()
  199.     {
  200.         $q = $this->db->query("select * from fc_template where active_status = 'Active'");
  201.         $q = $q->result_array();
  202.         foreach ($q as $row){
  203.             $output = $row["template_folder"];
  204.         }
  205.     return $output;
  206.  
  207.     }
  208. }
Advertisement
Add Comment
Please, Sign In to add comment