Welcome Guest, Not a member yet? Register   Sign In
Model files in CI4
#20

(09-05-2021, 03:39 PM)includebeer Wrote: Sorry for the very late reply. I was busy with "life"...
Anyway, like ikesela said, use the model() function to load a model. It will return a shared instance by default. So you you don't need to use a global variable, this is PHP 4 era mentality.  Cool

1)
Does this work in the subroutines in the libraries too?
I mean: in Library01.php methods I don't need to declare global $G_Mymodel01?

2)
I'm an old man, born with Commodore64's Basic. Maybe I'm not using objects in the best way...
But I can't imagine how to avoid global variables. My site is a game of strategy: the execute_move.php controller must load all the DB tables (80, more or less), then elaborate all orders, move units, solve combats, and so on; at the end, write the changes on the DB. I use 3 levels of subroutines, in 3 libraries. How can I do this, withot global objects?
Reply


Messages In This Thread
Model files in CI4 - by Filippo65 - 07-06-2021, 10:39 AM
RE: Model files in CI4 - by MGatner - 07-07-2021, 06:14 AM
RE: Model files in CI4 - by paliz - 07-07-2021, 09:17 AM
RE: Model files in CI4 - by Filippo65 - 07-12-2021, 10:06 AM
RE: Model files in CI4 - by includebeer - 07-12-2021, 03:44 PM
RE: Model files in CI4 - by InsiteFX - 07-12-2021, 09:04 PM
RE: Model files in CI4 - by davis.lasis - 07-13-2021, 03:29 AM
RE: Model files in CI4 - by Filippo65 - 07-14-2021, 11:18 AM
RE: Model files in CI4 - by includebeer - 07-14-2021, 02:23 PM
RE: Model files in CI4 - by Filippo65 - 07-19-2021, 10:57 AM
RE: Model files in CI4 - by includebeer - 07-19-2021, 02:45 PM
RE: Model files in CI4 - by Filippo65 - 07-20-2021, 10:52 AM
RE: Model files in CI4 - by Filippo65 - 07-20-2021, 12:47 PM
RE: Model files in CI4 - by Filippo65 - 07-21-2021, 10:30 AM
RE: Model files in CI4 - by includebeer - 07-23-2021, 04:52 AM
Model files in CI4 - by Filippo65 - 08-20-2021, 09:28 AM
RE: Model files in CI4 - by ikesela - 08-20-2021, 12:50 PM
RE: Model files in CI4 - by includebeer - 09-05-2021, 03:39 PM
RE: Model files in CI4 - by Filippo65 - 09-23-2021, 07:44 AM
RE: Model files in CI4 - by InsiteFX - 09-06-2021, 12:56 AM
RE: Model files in CI4 - by Filippo65 - 09-25-2021, 09:34 AM
RE: Model files in CI4 - by InsiteFX - 09-26-2021, 12:43 AM



Theme © iAndrew 2016 - Forum software by © MyBB