title: CodeIgniter, pass data from model to controller to display sql operations results in controller
body: <p>This is my <strong>Login controller</strong></p>
  
  <pre><code> &lt;?php if (! defined('BASEPATH')) exit('No direct script access allowed');
  
      class Login extends CI_Controller
      {
  
          function __construct()
          {
              parent::__construct();
  
          }
  
          public function index($msg = NULL)
          {
              $this-&gt;load-&gt;helper('url');
              // Load the model
              $this-&gt;load-&gt;model('login_model');
              // Validate the user can login
              $this-&gt;login_model-&gt;loginAction();      
          }   
      }
      ?&gt;
  </code></pre>
  
  <p>And my Model <strong>Login_model</strong> is</p>
  
  <pre><code>&lt;?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
  
  class Login_model extends CI_Model
  {
      function __construct()
      {
          parent::__construct();
  
      }
  
      public function loginAction()
      {
          // grab user input
          $email = $this-&gt;input-&gt;get('email');
          $password = $this-&gt;input-&gt;get('password');
  
          // Prep the query
          $this-&gt;db-&gt;where('email', $email);
          $this-&gt;db-&gt;where('password', $password);
  
          // Run the query
          $query = $this-&gt;db-&gt;get('users');
  
          foreach ($query-&gt;result() as $row)
          {
              $dbid= $row-&gt;id;
              $dbemail= $row-&gt;email;
          }
  
          $value=$query-&gt;num_rows();
          if($value == 1)
          {
              $details = array(
              'status'=&gt;'sucess', 
              'message'=&gt;'sucessfully logedin ',
  
              'id' =&gt; $dbid,
              'email' =&gt; $dbemail, 
              );
              echo  json_encode($details);
          }
          else
          {
              $detail = array(
              'status'=&gt;'failed', 
              'message'=&gt;'invalid email password ',
  
              );
              echo  json_encode($detail);
              return false;
          }
      }   
  }
  ?&gt;
  </code></pre>
  
  <p>This is working, but I need to use  <strong>$details</strong> &amp; <strong>$detail</strong> arrays in my <strong>Login controller</strong> to encode json data. for that what all modifications that I need to put in both my model and controller. I am new to codeIgniter. </p>