chrisweb wrote:
>
> Another solution i found, would be to add this code to my bootstrap file:
>
> $module_in_use = $this->_request->getModuleName();
>
> set_include_path(
> get_include_path() . PATH_SEPARATOR .
> '../library' . PATH_SEPARATOR .
> '../application/'.$module_in_use.'/models'
> );
>
> (i like this solution because only the class i need is loaded and not all
> the classes ... but i dont know if it will always work, also with a more
> complex website, in every situation, for example if i would use action
> stacks or stuff like that ?)
>
> are those really solutions or is the error somewhere before this point, is
> there one solution which is better then the other? do you have any tips to
> avoid such problems in the future? %-|
>
> Chris
>
This is the solution I'd use. Basically, a module can load classes only
from its own module. Or else add one single "library" directory outside the
modules hierarchy for code that can be used from any module.
What you are seeing is behavior common to path-searching mechanisms in many
programming environments. The order of entries in a path is significant,
because the environment will search them in order, and stop once it has
found a match.
For example, in the shell you could have two commands of the same name,
/usr/bin/more and /usr/local/bin/more. When you type 'more' at the prompt
the shell determines which one to use by the order of directories in your
PATH.
It works the same in the PHP include path. If you have two files of the
same name, but in different directory hierarchies listed in your include
path, PHP searches the directories in the order you declared them, loads the
matching file it finds first, and stops searching.
I think of the old adage that you always find something you're searching for
in the last place you look -- naturally, because there's no need to keep
looking after you've found it! :-)
Regards,
Bill Karwin
--
View this message in context:
http://www.nabble.com/multiple-models-with-same-name-%28m1-models-pages.php-and-m2-models-pages.php%29-tp19607614p19611162.html
Sent from the Zend Framework mailing list archive at Nabble.com.