Welcome Guest, Not a member yet? Register   Sign In
DB Using CodeIgniter’s Model - $afterFind
#5

(06-18-2020, 11:45 PM)midav Wrote: I only need reading, and I thought you can do it all through $afterFind

as I understand it, I need to write my processing function and call it so protected $afterFind = ['filmsCat'];

Yes, you are correct: with $afterFind = .. you define which method in your own model class the parent Model will call after data has been loaded from database. This method is totally yours to make, so here you can load any additional data you see fit. It will receive the original data loaded from DB as an argument. Just make note that the $data array you receive is built like this:
PHP Code:
$data = [
       'id' => <primary key of database row>,
       'data' => [
           // actual row data: key-value pairs
       ],
]; 

Please verify the above with var_dump or similar in your protected function filmsCat(array $data).
Reply


Messages In This Thread
RE: DB Using CodeIgniter’s Model - $afterFind - by bivanbi - 06-19-2020, 02:00 AM



Theme © iAndrew 2016 - Forum software by © MyBB