1

I am tring to translate my custom classes in a library for Codeigniter but I have this problem.

require_once "a.php";
require_once "b.php";

function __construct() {    
     $this->b = new b();
}

I changed the require and construct using the library loader.

function __construct() {
   $this->CI =& get_instance();
   $this->CI->load->library('a');
   $this->CI->load->library('b');
}

but now I need to convert this function but I don't know in which mode a can do that

public function addRecipient($first,$second){
   $a= new a($first);  // ??? new library a ?
   $a->header = 1;
   $a->set($second);     
   $this->b->add($a);     // passing object library a???
   return $a;
}

1 Answer 1

1

here is a logic that may help

make a admin controller and Amodel and Bmodel

load these model inside admin controller

class admin extends CI_Controller{

    function __construct()
    {

    $this-load>model('amodel');
    $this-load>model('amodel');

    }

 function index($first,$second){
 $a = $this->amodel->addRecipient($first,$second)
 $this->data['a'] = $a;
 $this->load->view('index',$this->data);
 }

so inside amodel.php file you can call bmodel.php functions like this

public function addRecipient($first,$second){
$a = new stdClass();
$a->header = 1;
$a->first = $first; 
$a->second= $second;
$a = $this->bmodel->get_todos($a);  
return $a;
}

inside bmodel.php function can be something like this

function get_todos($a){

$a->third =  $a->first + $a->second
return  $a;

 }
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.