#381: Doctrine integration
-----------------------------------+----------------------------------------
Reporter: [EMAIL PROTECTED] | Owner: david
Type: enhancement | Status: new
Priority: normal | Milestone: 1.0
Component: database | Version:
Severity: normal | Resolution:
Keywords: |
-----------------------------------+----------------------------------------
Old description:
> Hi all,
>
> Attached are two files for inclusion for Doctrine support:
>
> 1. !DoctrineAgaviDatabase.class.php - which handles the database
> connection via a full dsn in databases.xml (i.e.
> !mysql://root:[EMAIL PROTECTED]/doctrine) and handles the autoloading of
> classes as long as they follow the agavi Model format
> 2. !AgaviDoctrineRecord.class.php - which is a helper wrapper for the
> Models to implement
>
> So add them to the base autoload.xml and support for Doctrine is there!
>
> Example Usage:
> {{{
> #!html
> <pre>
>
> // Autoload - no longer used - use autoload.xml
> <strike>
> // Establish connection
> $conn = $this->getContext()->getDatabaseConnection();
> // Get the model
> $user = $this->getContext()->getModel('User');
> </strike>
>
> // Add your doctrine records to autoload.xml
> $user = new UserRecord;
> // Do something with the model
> $user->name = "Jack Daniels";
> $user->Email->address = "[EMAIL PROTECTED]";
> $user->Phonenumber[0]->phonenumber = "123 123";
> $user->Phonenumber[1]->phonenumber = "133 133";
> $user->Group[0]->name = "beer lovers";
> $user->Group[0]->Email->address = "[EMAIL PROTECTED]";
> $user->save();
> </pre>
> }}}
>
> ~~Note: Because Doctrine initiates any sub classes i.e. the Email class
> belonging to User is auto initiated by Doctrine it doesn't have access to
> context via getContext where as the User model does because we initiated
> it through getModel~~
>
> Note: Doctrine initiates any sub classes i.e. the Email class belonging
> to User is auto initiated by Doctrine and therefore User doesn't have
> access to the context its simpler not to extend !DoctrineRecord and use
> autoload.xml to get access to your models.
>
> Ross
New description:
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
[http://doctrine.pengus.net/trac/browser/trunk/lib 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
[http://trac.agavi.org/attachment/ticket/381/BaseDoctrineDatabase.class.php#L93
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: ==
{{{
#!html
<pre>
// Add your doctrine records to autoload.xml
$user = new UserRecord;
// Do something with the model
$user->name = "Jack Daniels";
$user->Email->address = "[EMAIL PROTECTED]";
$user->Phonenumber[0]->phonenumber = "123 123";
$user->Phonenumber[1]->phonenumber = "133 133";
$user->Group[0]->name = "beer lovers";
$user->Group[0]->Email->address = "[EMAIL PROTECTED]";
$user->save();
</pre>
}}}
Ross
--
Ticket URL: <http://trac.agavi.org/ticket/381#comment:9>
Agavi <http://www.agavi.org/>
An MVC Framework for PHP5
_______________________________________________
Agavi Tickets Mailing List
[email protected]
http://lists.agavi.org/mailman/listinfo/tickets