[Catalyst] Class::DBI, Controller::Root, set_sql "redefined"

Marc Brooks marc at xconcepts.com
Tue Jun 6 19:21:46 CEST 2006


The problem at hand though is the complexity of the statements I am using.
I use the set_sql() from the Class::DBI since I can naturally write my
statements.  Does the DBIx::Class have an equivalent of the set_sql()?

EXAMPLE:

        SELECT *
          FROM catalog AS node1, catalog AS node2
         WHERE node2.lft BETWEEN node1.lft AND node1.rgt
           AND $level = (     
               SELECT COUNT(*)
                 FROM catalog AS node3
                WHERE node3.lft BETWEEN node1.lft AND node1.rgt
                  AND node2.lft BETWEEN node3.lft AND node3.rgt
                  AND node3.id
                      NOT IN (node2.id, node1.id)
           )
           AND node2.id != node1.id AND node1.id = '$id'


-----Original Message-----
From: catalyst-bounces at lists.rawmode.org
[mailto:catalyst-bounces at lists.rawmode.org]On Behalf Of Aran Deltac
Sent: Tuesday, June 06, 2006 10:10 AM
To: The elegant MVC web framework
Subject: Re: [Catalyst] Class::DBI, Controller::Root, set_sql
"redefined" [heur] poss. spam[ff]


On 6/6/06, Marc Brooks <marc at xconcepts.com> wrote:
> The problem is the method doesn't exist until the query is executed using
> set_sql().
>
> When performing a query using
>
> $c->model('MyApp::Example')->set_sql( example => qq{
>     SELECT * FROM just_an_example WHERE just = 1
> });
>
> The Class::DBI inherits Ima::DBI's set_sql() to create a helper shortcut
> method, by prefixing the name of the SQL fragment with "search_". Thus,
the
> above call to set_sql() will automatically set up the method
> search_example(), which will then perform the query.

Its generally accepted by most Catalyst developers that DBIx::Class is
a superior solution to Class::DBI.  You'll find that DBIx::Class is
much more sane about how it handles these sorts of situations.
Consider making the switch if you can.  :)

Aran

> So the answer to your question is no because the method doesn't exist.
>
> Thanks for your time
>
> M. Brooks
>
> -----Original Message-----
> From: catalyst-bounces at lists.rawmode.org
> [mailto:catalyst-bounces at lists.rawmode.org]On Behalf Of Marcello Romani
> Sent: Monday, June 05, 2006 11:42 PM
> To: The elegant MVC web framework
> Subject: Re: [Catalyst] Class::DBI, Controller::Root, set_sql
> "redefined" [heur] poss. spam[ff]
>
>
> Marc Brooks ha scritto:
> > This is more of any annoying error message if anything.  So bear with
me.
> >
> > Basically I am setting global template variables (TT) within the
> > Controller::Root to be used within all the template pages within the
> > application.  Everything works with exception to this annoying warning,
> > "Model::CDBI::Catalog::sql_category redefined at
> > /usr/lib/perl5/site_perl/5.8.3/Ima/DBI.pm".
> >
> > I have narrowed the problem down to the Class::DBI set_sql() method and
> how
> > it temporarily creates a method sql_* within the Model::CDBI upon
> execution.
> >
> > Anyone experience this or know of a solution to suppress this warning?
> >
> > Is this something I should be worrying about?
> >
> > Thank your time, Catalyst::Rocks.
> >
> >
> >
> > _______________________________________________
> > Catalyst mailing list
> > Catalyst at lists.rawmode.org
> > http://lists.rawmode.org/mailman/listinfo/catalyst
> >
> >
>
> Sorry for the silly question, but have you tried renaming the method ?
>
> --
>
> Marcello Romani
> Responsabile IT
> Ottotecnica s.r.l.
> http://www.ottotecnica.com
>
> _______________________________________________
> Catalyst mailing list
> Catalyst at lists.rawmode.org
> http://lists.rawmode.org/mailman/listinfo/catalyst
>
> _______________________________________________
> Catalyst mailing list
> Catalyst at lists.rawmode.org
> http://lists.rawmode.org/mailman/listinfo/catalyst
>

_______________________________________________
Catalyst mailing list
Catalyst at lists.rawmode.org
http://lists.rawmode.org/mailman/listinfo/catalyst



More information about the Catalyst mailing list