[Dbix-class] Re: Complex(ish) select statement => DBIx::Class method

fREW Schmidt frioux at gmail.com
Thu Mar 12 15:55:38 GMT 2009


On Thu, Mar 12, 2009 at 10:23 AM, fREW Schmidt <frioux at gmail.com> wrote:

> Hello friends!
>
> We have the following SQL:
>
> (select date from logParents where id =3D 62),
>> (select max(logstatus.date) from logstatus
>> join logChildren on logChildren.id =3D logStatus.child_id
>> join logParents on logParents.id =3D logChildren.parent_id
>> where parent_id =3D 62)
>> ) as elapsed
>>
>
> We'd like to make it a method for the logParent, so one could just do
> $parent->elapsed_ms or something like that.  We are kindav at a loss as to
> how to do this.  Any tips at all would be extremely helpful.
>

Actually I pasted the SQL incorrectly...  here is what it should have been:

select datediff(millisecond,
	(select date from logParents where id =3D 62),
	(select max(logstatus.date) from logstatus
		join logChildren on logChildren.id =3D logStatus.child_id
		join logParents on logParents.id =3D logChildren.parent_id
		where parent_id =3D 62)
) as elapsed


-- =

fREW Schmidt
http://blog.afoolishmanifesto.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/dbix-class/attachments/20090312/a04=
a18c0/attachment-0001.htm


More information about the DBIx-Class mailing list