[Dbix-class] Re: JOIN question

Bernhard Graf dbic2 at augensalat.de
Wed Nov 29 08:36:06 GMT 2006


A. Pagaltzis wrote:

> * Bernhard Graf <dbic2 at augensalat.de> [2006-11-28 23:35]:
> > turned out that this cannot be easily achived, because of
> > shortcomings in SQL::Abstract, which doesn't support
> > placeholders in the FROM-part of a query.
>
> Neither does any database, so I don’t see it as a shortcoming.

Where did you get this?

I tried it with the mysql DBD driver and it worked. Of course there
might be drivers that don't support it.

Try this silly example (that also returns senseless results) with the
email database from my first email if you like:

use DBI;

my $dbh = DBI->connect("DBI:mysql:test");

my $sth = $dbh->prepare(<<'');
SELECT me.title
FROM email me
LEFT JOIN chunk chunks ON chunks.email=me.id
LEFT JOIN chunk chunks_2 ON chunks_2.email=me.id AND chunks.id!=chunks_2.id AND chunks.data=?
WHERE chunks.mimetype=? AND chunks_2.mimetype IS NULL

$sth->execute('foo', 'text/html');

$sth->bind_columns(\my ($title));

print "title = $title\n" while $sth->fetch;

-- 
Bernhard Graf



More information about the Dbix-class mailing list