> Why not just put if (!class_exists('Vehicle'))
> {require("Vehicle.php");} at the top of your scooter and car model
> files?
Won't work - the issue occurs even before that in basics.php, when
loading the models - it tries to load Scooter, for e.g. before
Vehicle. So even if you check if class_exists in Scooter, you get an
error when loadModels() in basics.php then tries to require (not
require_once) Vehicle, due to the fact that it is in the array
returned by listClasses().
> I would guess that require is used instead of require_once because
> *_once calls are slower (needs to check the file hasn't already been
> loaded, taking care of any server path magicary).
Yeah, that's what I figured. But it would still probably be quicker
than analyzing the inheritance tree. There are a couple of other ways
I can think of - notice in loadModels() there is already a check being
done -
if (!key_exists($model_fn, $loadedModels)) {
but sadly, this doesn't help us, since $loadedModels is a local var to
that function. If there way, say, a loadedModules singleton or
registry, both loadModels() and loadModel() could refer to it, and so,
in Scooter, one could do loadModel('Vehicle') and not cause a class
redeclaration.
--
Best,
Irfan Baig
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~----------~----~----~----~------~----~------~--~---