Let's say I have a table with users (id, firstname) and a table with pets (id, id_user, species, petname) and one model each representing the tables.
Now I query all users owning a cat:
$this->userModel = new UserModel();
$this->petModel = new PetModel();
$cat_owner = $this->userModel->find(
$this->petModel->where('species', 'cat')->findColumn('id_user')
);
There are cat owners - find() returns rows of all users owning a cat.
But no one holds an Iguana:
$iguana_owner = $this->userModel->find(
$this->petModel->where('species', 'iguana')->findColumn('id_user')
);
Incorrectly, now we receive all users because
$this->petModel->where('species', 'iguana')->findColumn('id_user') returns null and find() acts like findAll()
I know, the query could also be written using join or otherwise... but I don't understand why find(null) returns all rows, whats the idea behind it?
Or am I misunderstanding something about the models, what is the best practice?