Despite that, if you're running on MYSQL, remember that view support
is really REALLY bad.

If you've got more than one sub-select. or nested joins, mysql won't
use any indexes.....

On Feb 23, 4:32 am, Damien Lepage <damienlep...@gmail.com> wrote:
> Thanks for your suggestion Lawrence. But I don't like it because it requires
> an extra step and breaks the built-in task
> doctrine:build-all-reload-test-all (because I need my views created between
> DB build and tests).
>
> Thanks to the tutorial published on symfony blog yesterday, I found a way to
> get a more integrated solution, using the Event System.
>
> In my project configuration I register a new listener on post_command event
> (which is a built-in event of sfTask)
> $this->dispatcher->connect('command.post_command', array('DatabaseInit',
> 'createViews'));
>
> Then I have a hook to create my views exactly where I want:
> class DatabaseInit {
>   static public function createViews(sfEvent $event)  {
>     if( $event->getSubject() instanceof sfDoctrineInsertSqlTask ) {
>       // create views here
>     }
>   }
>
> }
>
> Damien
>
> 2009/2/21 Lawrence Krubner <lkrub...@geocities.com>
>
>
>
> > Damien Lepage wrote:
> > > Thanks for your help David.
> > > However, it seems to be different for doctrine. I tried it and it doesn't
> > > work.
>
> > > The help for *propel:insert-sql* says:
> > > The task connects to the database and executes all SQL statements found
> > in
> > > [config/sql/*schema.sql|COMMENT] files.
>
> > > But the help for *doctrine:insert-sql* says:
> > > The task connects to the database and creates tables for all the
> > > lib/model/doctrine/*.php files.
>
> > > Anybody knows how to execute custom SQL script with Doctrine ?
>
> > Why not just put this in a shell script and call it from the command
> > line? That's really all that the above mentioned propel or doctrine
> > commands do. It would take you, what, 5 minutes to write your own script?
>
> > --- lawrence
>
> > > 2009/2/17 David Herrmann <d...@okto.tv>
>
> > >> Damien Lepage schrieb:
> > >>> I would like to know if there is an easy way to automatically create
> > >>> views each time I rebuild my database.
> > >>> In other words, is there a place where I can put a custom script which
> > >>> will create my views and will be triggered when my database is built
> > (by
> > >>> doctrine:build-db I think).
>
> > >>> I read about using Views with Doctrine here:
>
> >http://www.doctrine-project.org/documentation/manual/1_0/en/component...
> > >>> But I miss information about how to integrate views when using doctrine
> > >>> in symfony.
> > >> I can only tell how I did it for Propel but I suppose it will work for
> > >> Doctrine, too: just put the SQL to generate your view into something
> > >> like /data/sql/my_view.sql and it will automatically be included during
> > >> DB build/create execution.
> > >> If there's a folder /data/sql/doctrine (can't find out atm) then that's
> > >> your place of course.
>
> > >> Just make sure your view code gets executed after all the other SQL
> > >> statements (so all tables exist). Symfony will order the SQL files by
> > >> name, so you can use the file name to change the order.
>
> > >> Hope that helps
>
> > >> David
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to 
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/symfony-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to