Welcome Guest, Not a member yet? Register   Sign In
Drop-in PHP Doctrine plugin
#21

[eluser]iDVB[/eluser]
[quote author="Nick Husher" date="1253560121"]Suggestion: Give it a try and let me know how it works. Wink

Doctrine and CodeIgniter are very loosely coupled in my plugin: it's basically just adding your Doctrine classes to the global namespace (if you load the Doctrine plugin somewhere in your request) and letting you do what you want. It should continue to work as long as the API to turn a schema into a set of class files and fixtures into database data haven't changed. I'm not an expert in Doctrine, but I don't see why 1.1 wouldn't work with the plugin. I don't know anything about Doctrine 2.0, so I can't speak to that.[/quote]

Thanks for the quick reply Nick. Can you maybe look at my other thread. I am thinking of switching to your plugin implementation if it will help fix my issue. Basically, I just interested in you to chime in on if you think you plugin will in-advertantly help me here...

http://ellislab.com/forums/viewthread/129635/
#22

[eluser]Nick Husher[/eluser]
No, it probably won't solve your problem. CI probably still won't be accessible within your Doctrine objects (although I don't know for sure, never tried it!). The way I've been using my plugin keeps all the hardcode Doctrine stuff at arms length by keeping it within the CI model files. I don't work directly on the generated Doctrine class files because I'm changing my schema enough that I want the flexibility to nuke all my models and rebuild them from yaml at will. Anything that needs CI to operate goes in a CI model, while my interface with the database is all Doctrine-powered. I don't know if that makes any sense to you at all
#23

[eluser]iDVB[/eluser]
I think I understand. However, I guess I'm still confused as to how most people use CI and Doctrine then.
Does it not make sense to be able to have a "User" object/Doctrine Class that has the ability to say...
User.login(password) and have that user now logged in.

In order to do that I'd need the CI Session class accessable from within that User Doctrine object/class.

I'm really just trying to wrap my head around how Doctrine is supposed to play with CI.

D
#24

[eluser]iDVB[/eluser]
I'm currently having two issues with this Doctrine plugin most likely due to me not understanding how to use it fully.

1) My "Doctrine_Manager::getInstance()->setAttribute()"s don't seem to work when I place them in the "doctrine_pi.php" file. Is this not where I should stick the code to get those working? Here is my code:

Code:
<?php

require_once 'doctrine'.DIRECTORY_SEPARATOR.'Doctrine.php';

@include APPPATH . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'database' . EXT;

define('DOCTRINE_DIRECTORY', APPPATH . DIRECTORY_SEPARATOR . 'doctrine' . DIRECTORY_SEPARATOR);
define('MODELS_DIRECTORY', DOCTRINE_DIRECTORY . 'models' . DIRECTORY_SEPARATOR);
define('FIXTURES_DIRECTORY', DOCTRINE_DIRECTORY . 'fixtures' . DIRECTORY_SEPARATOR);
define('SCHEMA_DIRECTORY', DOCTRINE_DIRECTORY . 'schema' . DIRECTORY_SEPARATOR);


// Set the autoloader
spl_autoload_register(array('Doctrine', 'autoload'));

//optional, you can set this to whatever you want, or not set it at all
//Doctrine_Manager::getInstance()->setAttribute('model_loading', 'aggressive');

Doctrine_Manager::getInstance()->setAttribute(Doctrine::ATTR_MODEL_LOADING, Doctrine::MODEL_LOADING_CONSERVATIVE);
Doctrine_Manager::getInstance()->setAttribute(Doctrine::ATTR_AUTOLOAD_TABLE_CLASSES, TRUE);
Doctrine_Manager::getInstance()->setAttribute(Doctrine::ATTR_AUTO_ACCESSOR_OVERRIDE, TRUE);

// Load the Doctrine connection
// (Notice the use of $active_group here, to make it easy to swap out
//  you connection based on you database.php configs)
...the rest is standard->

2) Whenever I use "doctrine_destroy_database" I get a bunch of PHP errors regarding relations in the DB that are preventing certain tables form being dropped before others. When I go into phpMyAdmin I get those same errors but if I just change the order in which I manually drop them it then works.


Any ideas what I'm doing wrong?
#25

[eluser]shinokada[/eluser]
CI-Doctrine - built for Doctrine 1.0 (included in package) link is broken.
Is there any new link available?
#26

[eluser]iDVB[/eluser]
In regards to the "doctrine_uninstall()" function:
I'm never able to execute this without receiving the error below. I consistently have to delete the DB and Models manually.
I understand this is due to foreign key constraints. However, don't most projects have these FKs, thus would that not mean that in most cases people would never be able to successfully use the "doctrine_uninstall()" or "doctrine_reinstall()" functions?

Maybe I'm doing something wrong? Can someone give me a bit of details here?

Code:
Fatal error: Uncaught exception 'Doctrine_Connection_Mysql_Exception' with message 'SQLSTATE[23000]: Integrity constraint violation: 1217 Cannot delete or update a parent row: a foreign key constraint fails' in /Projects/RB Projects/projects/gpsapp/www/system/plugins/doctrine/Doctrine/Connection.php:1075 Stack trace: #0 /Projects/RB Projects/projects/gpsapp/www/system/plugins/doctrine/Doctrine/Connection.php(1023): Doctrine_Connection->rethrowException(Object(PDOException), Object(Doctrine_Connection_Mysql)) #1 /Projects/RB Projects/projects/gpsapp/www/system/plugins/doctrine/Doctrine/Export.php(95): Doctrine_Connection->execute('DROP TABLE grou...') #2 /Projects/RB Projects/projects/gpsapp/www/system/plugins/doctrine_pi.php(83): Doctrine_Export->dropTable('group_table') #3 /Projects/RB Projects/projects/gpsapp/www/system/plugins/doctrine_pi.php(57): doctrine_destroy_database() #4 /Projects/RB Projects/projects/gpsapp/www/system/application/controllers/docsetup.php(8): doctrine_uninstall() #5 /Projects/RB Projects/project in /Projects/RB Projects/projects/gpsapp/www/system/plugins/doctrine/Doctrine/Connection.php on line 1075
#27

[eluser]iDVB[/eluser]
Bump
#28

[eluser]iDVB[/eluser]
Bump

No one can shed any light?
#29

[eluser]MarcelMarnix[/eluser]
[quote author="iDVB" date="1257287652"]Bump

No one can shed any light?[/quote]

I got my ci and doctrine work with this tutor.

Hope you can get something out of it
http://www.phpandstuff.com/articles/code...-and-setup
#30

[eluser]Beano[/eluser]
For anyone who is interested - I’ve posted up a project starter on my blog - a dev ready incorporation of the following technologies:

- ExtJS : client side JS library,
- CodeIgniter : presentation + domain tier,
- Doctrine : ORM data layer framework

Some features of this project starter are:
- CodeIgniter Models have been replaced with Doctrine Records
- Doctrine is loaded into CI as a plugin
- RoR type before and after filters….
- Doctrine transactions automatically wrapped around every action at execution time (ATOMIC db updates)

Basic Role based security (I think Redux may be in there as well?)
Simply extract, hook up the database.php config file and viola…. You can start coding your layouts, views and models. Probably a few things to iron out - but enjoy!

Hope it helps

GET IT AT: thecodeabode.blogspot.com




Theme © iAndrew 2016 - Forum software by © MyBB