#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
>
> Ross

New 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

Comment (by ross):

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

 Use !BaseDoctrineDatabase.class.php instead.

-- 
Ticket URL: <http://trac.agavi.org/ticket/381#comment:6>
Agavi <http://www.agavi.org/>
An MVC Framework for PHP5


_______________________________________________
Agavi Tickets Mailing List
[email protected]
http://lists.agavi.org/mailman/listinfo/tickets

Reply via email to