CodeIgniter Forums
ci2 + doctrine2 - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: ci2 + doctrine2 (/showthread.php?tid=38454)



ci2 + doctrine2 - El Forum - 02-08-2011

[eluser]Unknown[/eluser]
Hi!

I just followed this tutorial here and everything seems to work very well.
But what is the best way to manipulate/fetch data from the database?
I suggest that a data access object will be very good to interact with the database.
So I tried to create a new model for data access, but when I try to use
Code:
$this->doctrine->em
I always get the error that the property $doctrine is not set.
When I use the above code in my controller everything works fine!?

Do anybody have an idea to solve this problem?
Or is there a better way to access data with doctrine?

Kind regards,
Konrad


ci2 + doctrine2 - El Forum - 02-08-2011

[eluser]portgaz[/eluser]
Did you try to autoload the doctrine library in your new php file?


ci2 + doctrine2 - El Forum - 02-08-2011

[eluser]Unknown[/eluser]
yes doctrine is set in the autoload file.
When I specify
Code:
$this->doctrine = new Doctrine()
then I get the error message, that the $db varibale cannot be read, which is specified in the database.php config file (which is used by the Doctrine class).

are there best practices how to handle data with doctrine?


ci2 + doctrine2 - El Forum - 03-07-2011

[eluser]Unknown[/eluser]
For some reason, when you try to call the Doctrine class from the model it does throws exceptions. From what I can see the Doctrine class created in the library can only be instantiated from from the controller. I hope there's more tutorials on how to use CI + doctrine 2 (this is totally different from previous version and the documentation is not very clear on how to use it as well.)


ci2 + doctrine2 - El Forum - 03-08-2011

[eluser]gowrav vishwakarma[/eluser]
Have you tried with Doctrine 1.2.2 with CI 1.7.3 before or you are getting errors their also, its used as plugins instead of library and we are using it from almost 8 months heavily in our projects without any problem. It is autoloaded in our projects..