Ticket #381 (closed enhancement: fixed)

Opened 5 years ago

Last modified 9 months ago

Doctrine integration

Reported by: ross.lawley@… Owned by: david
Priority: normal Milestone: 0.11
Component: database Version:
Severity: normal Keywords:
Cc: Patch attached:

Description (last modified by ross) (diff)

Hi all,

Attached is the BaseDoctrineDatabase class for inclusion for Doctrine support. Please add it with any other Doctrine Record / Table / EventListener Models to the base autoload.xml and support for Doctrine is there!

Please Note (I may have a wierd setup!)

I have added a !core.libs_dir to the config and package the  Doctrine lib application in a libs directory off my project route.

If you package yours elsewhere (or checkout the whole Doctrine source) then you will need to edit  line 93 - to use the correct config path and point to the actual Doctrine/lib directory (the one that contains Doctrine.php and the Doctrine directory).

Example Usage:

  // Add your doctrine records to autoload.xml
  $user = new UserRecord; 
  // Do something with the model
  $user->name = "Jack Daniels";
  $user->Email->address = "jackdaniels@drinkmore.info";
  $user->Phonenumber[0]->phonenumber = "123 123";
  $user->Phonenumber[1]->phonenumber = "133 133";
  $user->Group[0]->name = "beer lovers";
  $user->Group[0]->Email->address = "beerlovers@drinkmore.info";
  $user->save();

Ross

Attachments

BaseDoctrineDatabase.class.php Download (3.2 KB) - added by ross 5 years ago.

Change History

Changed 5 years ago by david

  • summary changed from Doctrine Inclusion to Doctrine integration
  • component changed from _OTHER_ to database
  • version HEAD deleted
  • milestone changed from 0.11 to 1.0

We should integrate it fully for v1.0, along with Propel, so each record also gets the Context etc (good for sending email notifications on product save or so)

Changed 5 years ago by MikeSeth

Awesome! I will be testing this tomorrow.

Changed 5 years ago by RossC0

Added a new version,

Removed autoloading functionality as that can be handled but autoload.xml (also as DoctrineTables and DoctrineEventListeners are optional, seemed overkill to try and determine their whereabouts).

I also expect doctrine to be in the following location:

AgaviConfig::get('core.libs_dir').'/doctrine/Doctrine.php'

Again feel free to configure differently.

As its not an official class, I've prefixed it Base - I store all my Base classes in app/lib and thats where I extend any Agavi functionality for my current app.

Ross

Changed 5 years ago by ross

Changed 5 years ago by ross

Updated to use AgaviToolkit::expandDirectives

Changed 5 years ago by ross

  • description modified (diff)

Changed 5 years ago by ross

  • description modified (diff)

AgaviDoctrineDatabase.class.php and AgaviDoctrineRecord.class.php have been depreciated - don't use.

Use BaseDoctrineDatabase.class.php instead.

Changed 5 years ago by MikeSeth

Ross, there's a bug in your BaseDoctrineBase? (line 94):

require(AgaviConfig::get('core.lib_dir').'/doctrine/Doctrine.php');

In your version, it's libs_dir and not lib_dir. I presume you have your lib/ in the include path so it doesn't show, but under XAMPP the bug is obvious.

Changed 5 years ago by ross

Apologies,

I define core.libs_dir in my config.php - and package all my external libraries (including agavi) there.

Feel free to point to your doctrine install wherever it may be.

Ross

Changed 5 years ago by ross

  • description modified (diff)

Changed 5 years ago by ross

Description updated thanks to Mikes prompting! Old (out of date) files removed.

Changed 5 years ago by david

(In [2084]) AgaviDoctrineDatabase? first prototype, refs #381. This will connect to doctrine for you automatically (lazy connecting!) and hopefully also manages multiple connections. getDoctrineManager() gives the manager, getResource() gives the PDO connection, getConnection() will give the doctrine connection object. The latter two cause doctrine to connect. connect() does nothing. Enjoy. Table/Connection mapping is coming next. Add "Doctrine" class to your autoload.xml for maximum pleasure.

Changed 5 years ago by david

  • status changed from new to assigned

(In [2089]) support for setting attributes on a connection, use param "attributes" as an array (name => value like "AUTO_LENGTH_VLD", without Doctrine::ATTR_) and "bind_components", an array of component names to bind to this connection

Changed 5 years ago by david

  • milestone changed from 1.0 to 0.11

Changed 5 years ago by david

  • status changed from assigned to closed
  • resolution set to fixed

I think the way it works now it's okay. More features may be added over time.

Note: See TracTickets for help on using tickets.