Page 1 of 1

More Grafted fields [SOLVED]

PostPosted: Tue May 25, 2010 9:08 am
by cantlep
Hiya,

I thought I'd got my head round this but clearly not.

In a table called "ContractData" I have some fields that will be populated. What I'd like to do is get some of those fields (there are about 5 in total) to also show up in another table called "BillData".

So, (just testing one of the fields here) in BillData/BillData.php, I did this.
Code: Select all
function __sql__(){
        return "select f.*, f.WinningSupplierStandingChargeType AS WinningSupplierStandingChargeType FROM ContractData f";
}


Here I thought I was basically saying grab me the WinningSupplier..... column from ContractData and call it the same thing in BillData.

It errors in the apache logs saying it's a duplicate column. So I guess it's trying to put in into ContractData again instead of BillData. That command works from the CLI though.

Can you help please?

Thanks

Paul

Re: More Grafted fields

PostPosted: Tue May 25, 2010 9:33 am
by shannah
The __sql__ method ( or the __sql__ directive in the fields.ini file) is meant to provide an alternative "select" statement for loading the records of the given table. It should include a superset of the columns and an equivalent set of rows.

For some more details, please see:
http://xataface.com/wiki/sql_delegate_method

Also check out this excerpt from the unfinished and unreleased Xataface manual that pertains to the __sql__ directive. Hopefully it helps a bit.
http://dev.weblite.ca/xataface-manual-pp.113-116.pdf

Re: More Grafted fields

PostPosted: Tue May 25, 2010 9:58 am
by cantlep
Thanks Steve,

I was being a tool anyway..I had no common denominator between the 2 tables..so how would it know which column data to use! D'OH.

I'll have a look through the docs you sent.

Cheers

Paul