Welcome Guest, Not a member yet? Register   Sign In
how do I combine two libraries into one controller
#1

[eluser]my9006ci[/eluser]
help me please,

i have some library like this,
Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Jadwalsholat {

    var $CI = null;
    public function __construct(){
        $this->CI =& get_instance();
        $this->CI->load->model("modul"); // require
    }
    function index()
    {
        $result = '';
        $menu = $this->CI->modul->get_modul(1);
        if ($menu->num_rows() > 0)
        {
            foreach ($menu->result() as $row)
            {
                $result .= 'mochammad';
            }
        }
        return $result;
    }
}

?>

and

Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Jadwalsholat2 {

    var $CI = null;
    public function __construct(){
        $this->CI =& get_instance();
        $this->CI->load->model("modul"); // require
    }
    function index()
    {
        $result = '';
        $menu = $this->CI->modul->get_modul(1);
        if ($menu->num_rows() > 0)
        {
            foreach ($menu->result() as $row)
            {
                $result .= 'yalinulloh';
            }
        }
        return $result;
    }
}

?>

how do I combine two libraries into one controller
#2

[eluser]vitoco[/eluser]
It doesn't have much sense to write controllers without output...but it goes like this.
Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Jadwalsholat extends Controller {

    function Jadwalsholat()
    {
        parent::Controller();
        $this->load->model("modul"); // require
    }

    // Jadwalsholat->index => f1
    function index()
    {
        $result = '';
        $menu = $this->modul->get_modul(1);
        if ($menu->num_rows() > 0)
        {
            foreach ($menu->result() as $row)
            {
                $result .= 'mochammad';
            }
        }
        
        return $result;
    }

    // Jadwalsholat2->index => f2
    function f2()
    {
        $result = '';
        $menu = $this->modul->get_modul(1);
        if ($menu->num_rows() > 0)
        {
            foreach ($menu->result() as $row)
            {
                $result .= 'yalinulloh';
            }
        }
        return $result;
    }
}

?>




Theme © iAndrew 2016 - Forum software by © MyBB