vendredi 4 mars 2016

If-else statement not working correctly in codeigniter

I've had this problem for several hours now and I cannot for the life of me figure out what's wrong... I am no code pro so I'm probably missing something really simple. What I want to do is transfer data from my controller method to my model. Please tell me how to solve this in the best way.

The controller:

class Some_controller extends CI_Controller {

    function controller_method() {
        $this->load->model('Some_model');

        $boolean = /* get tiny int */;
        $data['result'] = $this->Some_model->do_stuff();
        $this->load->view('Some_view', $data);
    }
}

The model:

   class Some_model extends CI_Model {

        private $var;

        function __construct() {
            $boolean ? $this->var= 100 : $this->var = 1000;
            parent::__construct();
        }

        function do_stuff() {
            $data = $this->var;
            /* manipulate $data */
            return $data;
        }
    }

The view:

...
<p><?php echo $result; ?></p>
...

Aucun commentaire:

Enregistrer un commentaire