What is CI4 model findAll() with conditions?
Why Interviewers Ask This
This question targets practical, hands-on experience with CodeIgniter. Interviewers want to see if you've worked with these concepts in real projects, not just read about them. Strong answers include concrete examples.
Answer
CI4 models provide a fluent interface for querying with conditions. Chain Query Builder methods before terminal methods: $this->userModel->where("active", 1)->where("role", "editor")->orderBy("name")->findAll(10) — the integer argument to findAll() is the limit. Offset: findAll(10, 20) — 10 results starting from position 20. Find by primary key: find($id) (one) or find([1, 2, 3]) (array). First match: $this->userModel->where("email", $email)->first(). Convenience methods: findColumn("name") returns an array of values for one column. whereIn("id", $ids)->findAll() for IN queries. Check existence: $this->userModel->where("email", $email)->countAllResults(). The model returns the $returnType class (array or Entity) for each result. Use asArray() or asObject() temporarily: $this->userModel->asArray()->find(1).
Pro Tip
Back up your answer with a specific project or situation. Saying 'In my last CodeIgniter project, I used this when...' immediately makes your answer more credible and memorable.
Previous
What is CI4's supported database drivers?
Next
What is output caching vs data caching in CodeIgniter 4?