[eluser]quest13[/eluser]
Hi,I am new to CI and I need help on the following issue due to which my entire work is stalled.
After I insert my product details, i want to assign session variable to Productid which is the primary key of the table.Later, I want to use the same Productid when I update or Back or Skip to the various interview stages of product updation.
I insert 3 fields initially, but I update as I move on further ( like a interview navigation).On doing so, at times, either I come back to the previous page or skip certain page.In this scenario, I am not able to keep the Productid in session. ( I am new to CI, I know how it is done otherwise). Ofcourse, $this->db->insert_id() or $this->db->affected_rows()helped certain extent but fails when I go back or skip.
$query=$this->db->query("INSERT INTO product(productname,qty,price) VALUES('".$prodname."','".$qty."','".$price."')");
$lastrow = $this->db->insert_id();
if($lastrow >0){
$row = $query->row_array();
$this->session->sess_create();
$this->session->set_userdata($row);
$id=$row['PropertyId'];
The above code gives an error of "Call to a member function row_array() on a non-object"
The same in case of "result_array()" too.
When I tried to use the $id in other function, it doesn't recognize it.I think the session is not set at all for the product id.
Any help on this is highly appreciated.
Thank you in advance.