CodeIgniter Forums
using input->post in model? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: using input->post in model? (/showthread.php?tid=62619)



using input->post in model? - alexandervj - 08-05-2015

I'm trying to get values from the user input and use them in a where statement in the model, something like $this->db->where('partName, $this->input->post("partName")');

but I'm pretty sure I cant do that. Is there a way to use those input values in the model like I want to do though? Thanks


RE: using input->post in model? - pdthinh - 08-05-2015

(08-05-2015, 02:48 PM)alexandervj Wrote: I'm trying to get values from the user input and use them in a where statement in the model, something like $this->db->where('partName, $this->input->post("partName")');

but I'm pretty sure I cant do that. Is there a way to use those input values in the model like I want to do though? Thanks

You can do that

PHP Code:
class Some_model extends CI_Model {
 
   public function __construct() {
 
       parent::__construct();
 
       // ...
 
   }
 
   public function do_something() {
 
       // ...
 
       $this->db->where('partName'$this->input->post("partName"));
        
// ...
 
   }




RE: using input->post in model? - alexandervj - 08-06-2015

Not sure why it wasn't working for me, I'll try again. Thanks!


RE: using input->post in model? - pdthinh - 08-06-2015

(08-05-2015, 02:48 PM)alexandervj Wrote: $this->db->where('partName, $this->input->post("partName")');

You must notice the single quote inside the where(). It should be

PHP Code:
$this->db->where('partName'$this->input->post("partName")); 



RE: using input->post in model? - alexandervj - 08-06-2015

Thanks again!