title: How to access a value in a function for entire model in codeigniter
body: <p>I am using codeigniter. Now i have id  in a variable in one method of a model. I want to access the value where i used the variable for entire model(ie, all function of a model). </p>
  
  <p>Controller:::</p>
  
  <pre><code>public function user_id()
  {
      if(!empty($_POST['name']))
      {
          if(isset($_POST['name']))
          {
              $name =$this-&gt;input-&gt;post('name');                                                      //echo "Posted:".$name;
              $this-&gt;UserRight_model-&gt;get_id($name);      
          }
      }   
  }
  </code></pre>
  
  <p>Moldel code:</p>
  
  <pre><code>public function get_id($name)   
  {
      $query = $this-&gt;db-&gt;query("select UserPcKey from UserMaster where UserName='".$name."'");
      if ($query-&gt;num_rows() &gt; 0) 
      {
         foreach ($query-&gt;result() as $row)
         {
                $id= $row-&gt;UserPcKey;                                                    
                echo $pckey;
          }
      }
      else 
      { 
          echo "choose valid name"; 
      }                                                                                                   
  }
  </code></pre>
  
  <p>I tried to use the id value in other function in a same model i got error due to parameter.</p>