How to use a PHP MVC Controller, one thats invoked by calling a URL, to call and execute more than one function? [duplicate]



PHP Snippet 1:

public function firstPage()
{
   $foo = $this->getBar();
   // Load first page view
}

public function secondPage()
{
   $foo = $this->getBar();
   // Load second page view
}

protected function getBar()
{
   return 'Bar';
}

PHP Snippet 2:

protected function getBar()
{
   return new Bar();
}

PHP Snippet 3:

    class Test1 extends CI_controller
    {
        function testfunction(){
            return 1;
        }
    }

PHP Snippet 4:


    include 'Test1.php';
    
    class Test extends Test1
    {
        function myfunction(){
            $this->test();
            echo 1;
        }
    }

PHP Snippet 5:

    class Custom extends CI_Model
    {
        public function __construct()
        {
            parent::__construct(); 
        }
    
        function selectAll($Qry)
        {
            $query = $this->db->query($Qry);
            $DataRetuen = $query->result();
            if ($DataRetuen) {
                return $DataRetuen;
            } else {
                return 0;
            }
        }
    
        function Insert($Data, $idReturn, $table, $getLastId = 'N')
        {
            $insert = $this->db->insert($table, $Data);
            if ($insert) {
                if ($getLastId === 'Y') {
                    $returnValue = $this->db->insert_id();
                } elseif (!isset($Data[$idReturn]) || $Data[$idReturn] == '') {
                    $returnValue = 1;
                } else {
                    $returnValue = $Data[$idReturn];
                }
                return $returnValue;
            } else {
                return FALSE;
            }
        }
    
        function Edit($Data, $key, $value, $table)
        {
            $this->db->where($key, $value);
            $update = $this->db->update($table, $Data);
            if ($update) {
                return 1;
            } else {
                return 0;
            }
        }
     }

PHP Snippet 6:

    class Test extends CI_controller
    {
    
        function myfunction()
        {
            $this->load->model('custom');
            $ModelCustom = new Custom();
            $Arr = array();
            $Arr['sql_key'] = 'value';
            $responseArray = $ModelCustom->Edit($Arr, 'primary_key',    'primary_key_value', 'table_in_db');
            $this->load->view('my_view', $responseArray);
        }
        
    }