Hi I want to check query result. If it's null I want to send data to DB. In my code even if result is null I can't update database.
$this->db->where('login',$data_db['login']); $query = $this->db->get('users'); if(is_null($query)) // If Login doesn't exist in DB { $this->db->insert('users', $data_db); // Insert into DB } }
I was trying to do that in other way but If user doesn't exist I got “Trying to get non object etc”
Other way:
$this->db->where('login',$data_db['login']); $query = $this->db->get('users'); $row = $query->row(); if($row->login) { $this->load->view('content/error'); } else { $this->db->insert('users', $data_db); }