• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
DMZ - How to resolve object naming conflict?

#6
[eluser]oooobs[/eluser]
[quote author="nottRobin" date="1268821410"]I installed PHP 5.3.2 just so I could take advantages of namespaces. Then I added "namespace Model;" to the top of my Model class.
Code:
namespace Model;
class Model_participant extends \DataMapper {
    var $table = 'participant';
    var $has_one = array('organisation' => array('class' => 'organisation', 'other_field' => 'participant'));
}
/* End of file model_participant.php */
And changed the reference to it:
Code:
class Participant extends Controller {
    function index() {
        $p = new \Model\Model_participant();
        $p->get(); // No error :)
    }
}
/* End of file participant.php */
However, I get this error:
Code:
Fatal error: Class 'Model\Model_participant' not found in /path/to/application/controllers/participant.php on line 22
After much investigation I discovered that the reason for this is that the class Model_participant doesn't actually get loaded at compile-time. It somehow gets stored by DMZ until it's needed and then loaded. And DMZ thinks it's called Model_participant, not Model\Model_participant.

I don't think there's an easy solution to this so I should probably give up. If anyone does have any suggestions please go ahead and let me know Smile

Robin.[/quote]


I have the same problem? Smile I wish I know how to solve this Datamapper namespace issue


Messages In This Thread
DMZ - How to resolve object naming conflict? - by El Forum - 03-14-2010, 04:51 PM
DMZ - How to resolve object naming conflict? - by El Forum - 03-14-2010, 06:21 PM
DMZ - How to resolve object naming conflict? - by El Forum - 03-14-2010, 06:45 PM
DMZ - How to resolve object naming conflict? - by El Forum - 03-14-2010, 07:37 PM
DMZ - How to resolve object naming conflict? - by El Forum - 03-16-2010, 11:23 PM
DMZ - How to resolve object naming conflict? - by El Forum - 03-03-2011, 12:43 PM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.