[Dbix-class] How do I determine whether a column name is valid?
Christopher H. Laco
claco at chrislaco.com
Sun Nov 5 19:52:24 GMT 2006
Josef Karthauser wrote:
> Hi there,
> =
> I'm getting up to speed on DBIx::Class, in the context of Catalyst.
> Can someone help me with this query?
> =
> I need to validate whether a particular column exists in the schema
> before calling a search, as I get an SQL error if it doesn't exist.
> =
> I'm doing something like this:
> =
> my $order_by =3D $c->request->params->{order_by} || $default_orde=
r;
> my $rs =3D $c->model('Domain')->
> search(undef,
> { page =3D> $page, rows =3D> 10,
> order_by =3D> $order_by,
> prefetch =3D> ['registrant', 'owner']
> });
> =
> So, the value of order_by can be something like 'domainname' or
> 'owner.username'.
> =
> How do I check with D::C whether the column exists before feeding it to
> search, which expects it to exist? I've scanned loads of manual pages,
> but can't find anything relevant.
> =
> Thanks for you help :),
> Joe
http://search.cpan.org/~blblack/DBIx-Class-0.07999_01/lib/DBIx/Class/Result=
Source.pm#has_column
model('Domain')->result_source->has_column('foo');
-=3DChris
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: OpenPGP digital signature
Url : http://jules.scsys.co.uk/pipermail/dbix-class/attachments/20061105/d2=
fd92f4/signature.pgp
More information about the Dbix-class
mailing list