================================<br>WHAT I'M TRYING TO DO:<br>================================<br>I have three tables: photos, galleries, tags.<br>In Catalyst, I'm trying to retrieve photo info by <br>searching on photos, joined to their tags, and joined<br>to the galleries table that the photo's filesystem <br>location. <br>================================<br>MY APPROACH (I'm open to another, if there's a better way)<br>================================<br>I *think* I need to search on photos table, and join galleries<br>and tags; but I can't seem to get the syntax right, or <br>I've done some silly thing in my setup.<br><br>I've tried variations of this, to no avail:<br><br>my $photo_obj = $c-&gt;model('CatapultDB::Photos')-&gt;search(<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'tags.tag' =&gt; "$tag",
 <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; },<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; join =&gt; [qw/ tags galleries /],<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; )-&gt;page($page);<br><br>================================<br>SCHEMA DETAILS:<br>================================<br>CREATE TABLE Photos (<br>&nbsp; id&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SERIAL&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; NOT NULL PRIMARY KEY,<br>&nbsp; gallery&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; INTEGER NOT NULL<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 references Galleries(id)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ON DELETE CASCADE,<br>&nbsp; name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; VARCHAR(150) NOT NULL,<br>&nbsp; filename&nbsp;&nbsp;&nbsp;&nbsp; VARCHAR(150) NOT NULL,<br>);<br><br>In Photos class:<br>__PACKAGE__-&gt;belongs_to("gallery", <br>"Catapult::Schema::CatapultDB::Galleries", <br>{ id =&gt; "gallery" });<br>__PACKAGE__-&gt;has_many("tags", <br>"Catapult::Schema::CatapultDB::Tags", <br>{ "foreign.photo" =&gt; "self.id" });<br>================================<br>CREATE TABLE tags (<br>&nbsp; id&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SERIAL&nbsp; NOT NULL PRIMARY KEY,<br>&nbsp; photo&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; INTEGER REFERENCES photos(id)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ON DELETE RESTRICT,<br>&nbsp;
 tag&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; VARCHAR(100) NOT NULL<br>);<br><br>In Tags class<br>__PACKAGE__-&gt;belongs_to("photos", <br>"Catapult::Schema::CatapultDB::Photos", <br>{ id =&gt; "photo" });<br>================================<br>CREATE TABLE Galleries (<br>&nbsp; id&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SERIAL&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; NOT NULL PRIMARY KEY,<br>&nbsp; name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; VARCHAR (150) UNIQUE NOT NULL,<br>&nbsp; directory&nbsp;&nbsp;&nbsp; VARCHAR(50)&nbsp;&nbsp; UNIQUE NOT NULL,<br>);<br><br>In GAlleries class:<br>__PACKAGE__-&gt;has_many("photos", <br>"Catapult::Schema::CatapultDB::Photos", <br>{ "foreign.gallery" =&gt; "self.id" },<br>);<br><br>NOTE, I have found that this query works in psql:<br><br>SELECT *<br>FROM photos<br>JOIN galleries<br>ON photos.gallery = galleries.id<br>JOIN tags<br>ON photos.id = tags.photo<br>WHERE tags.tag =
 'sunshine';<br><br>/dennis<br><br><br>