Entities not uses by model with custom model method |
Hy everyone,
I'm new on this forum, and totally novice on CI4. I've been working on CI2 for soooo manu years and on CI3 since 2019, but, with CI4, it's a new world opening to me !!! I am discovering the Entities concept, it looks vers convenient but I'm really not comfortable with it even if I read the documentation about Model's and Entities. Here's my problem : I've got a simple model "PaysModel" (countries), it works with Pays entity. When I call A find() or findAll() method, it works find. But, I need to modify the findAll() behavior : actually I need all countries with "France" in first position. So, in order to do that, I've tryied 2 things : - Create a findAll() method in my model - Create a findAll2() (juste for the test) in my model. Both of them works find but don't return Entities. Could anybony explain me why and what to do ? Actually I want my method to return an array of row where each rows in an entity of Pays. This is my model : PHP Code: namespace App\Models; Here is my Entity : PHP Code: namespace App\Entities; And here is the way my call in controller : PHP Code: use App\Models\PaysModel;
Your function doesn't return entities because you're calling the query builder. The functions that will return an Entity object are find() and findAll() from the Model class. You can use WHERE clauses with findAll(). I'm not sure about the FIELD() function...
PHP Code: $listePays = $Pays |
Welcome Guest, Not a member yet? Register Sign In |