[Dbix-class] search vs. find

John Goulah jgoulah at gmail.com
Wed Jun 6 23:00:01 GMT 2007


On 6/6/07, Brandon Black <blblack at gmail.com> wrote:
>
> On 6/6/07, John Goulah <jgoulah at gmail.com> wrote:
> >
> > Ok, I appreciate the help, but rather than reiterating what I already
> had in
> > the initial post as responses, how about a real answer?
>
> The fact that you don't like the answers doesn't make them fake.  It
> would be easier to learn to work with the API the way it was meant to
> be used, instead of fighting with it.



Its not that I didn't like the answers or said they were "fake", its that
they were just reiterating something I had already stated so they were quite
obvious.  If you read my post I did say: "this makes some sense since search
may return many rows while find is designed to find one row."

I just figured since both things returned are "results" that perhaps it was
possible to cast from one to the other (however I dont know the internals of
the code).  I'm not fighting the API, I'm just trying to understand it
better.


> Anyway I found the
> > answer myself, for anyone interested:
> >
> > From DBIx::Class::Manual::Cookbook
> > (
> http://search.cpan.org/~mstrout/DBIx-Class-0.07000/lib/DBIx/Class/Manual/=
Cookbook.pod#Retrieving_a_row_object
> > )
> >  my $schema =3D $cd->result_source->schema;
> >  my $artist_rs =3D $schema->resultset('Artist');
>
> I don't see how this has anything to do with your question, are you
> sure it does what you think it does?  The snippet you posted is for
> getting a $schema object from a row object.  Your question was how to
> obtain a resultset object which represents a single row.



Actually this gets the schema, and the resultset object out of that.  The
object that comes out of this is the same object that is returned from
search. The only reason I posted back is b/c I thought someone else may
benefit from the fact that you can get this out of there if you need to for
some reason, in my case, I'll just use search.


Thanks,
John
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/dbix-class/attachments/20070606/ac4=
3c225/attachment-0001.htm


More information about the Dbix-class mailing list