Welcome Guest, Not a member yet? Register   Sign In
using input->post in model?
#1

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
Reply
#2

(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"));
        
// ...
 
   }

Reply
#3

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

(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")); 
Reply
#5

Thanks again!
Reply




Theme © iAndrew 2016 - Forum software by © MyBB