Page 1 of 1

How to return multiple results using sql delegate [SOLVED]

PostPosted: Thu Mar 18, 2010 7:34 am
by cantlep
Hi,

As per this link - http://xataface.com/wiki/sql_delegate_method I can create a function that uses __sql__ for table grafting. All works fine. However, I want to do it to 2 columns. I know I can't return more than once, but if I just create anotehr function __sql__ entry, it errors.

How can I have both columns grafted. i.e.
Code: Select all
function __sql__(){
        return "select c.*, s.TotalSites from Customers c left join CustomerStats s on c.CompanyName=s.CompanyName";
        }

function __sql__(){
        return "select c.*, s.TotalContracts from Customers c left join ContractStats s on c.CompanyName=s.CompanyName";
       }


type of thing.

Cheers

Re: How to return more than one result using sql delegate class

PostPosted: Thu Mar 18, 2010 8:48 am
by cantlep
Sorry, I keep posting and then figuring out the answer. This worked

Code: Select all
function __sql__(){
        return "select c.*, s.TotalSites,r.TotalContracts from Customers c left join CustomerStats s on c.CompanyName=s.CompanyName left join ContractStats r on c.Companyname=r.CompanyName";
}


Cheers