PEAR_ERROR [SOLVED]

A place for users and developers of the Xataface to discuss and receive support.

PEAR_ERROR [SOLVED]

Postby cantlep » Wed Sep 22, 2010 3:15 am

Hiya,

I really hope this isn't because of the Xataface arithmetic issues...but... I have this sql in my table delegate class
Code: Select all
function __sql__() {
return "ContractData.ContractSupplier1, (ContractData.ContractSupplier1DayRate * MPANData.DayCons) AS Test_Total FROM ContractData inner join MPANData_ContractData ON ContractData.ContractDataID = MPANData_ContractData.ContractDataID inner join MPANData ON MPANData_ContractData.MPANCore = MPANData.MPANCore";
}

which returns fine on the CLI
Code: Select all
+---------------------+------------+
| ContractSupplier1   | Test_Total |
+---------------------+------------+
| Scottish & Southern |  150000000 |
+---------------------+------------+

but just shows a blank web page. Here's the error from the web logs.
Code: Select all
[Wed Sep 22 11:19:18 2010] [error] [client 10.0.10.51] PHP Fatal error:  Cannot use object of type PEAR_Error as array in /var/www/html/public/dataface/Dataface/Table.php on line 2044, referer: http://www.site.org.uk/index.php

Any ideas?
Last edited by cantlep on Fri Sep 24, 2010 7:48 am, edited 1 time in total.
cantlep
 
Posts: 172
Joined: Fri Mar 05, 2010 2:14 am

Re: PEAR_ERROR

Postby cantlep » Fri Sep 24, 2010 2:13 am

Hi Steve,

if this is an arithmetic issue that you're already aware of..is there anyway I can make it a view that I can use?

Thanks

Paul
cantlep
 
Posts: 172
Joined: Fri Mar 05, 2010 2:14 am

Re: PEAR_ERROR

Postby cantlep » Fri Sep 24, 2010 5:53 am

OK, getting a bit further, I put in some debugging into Table.php (found from another issue in another post) and that highlighted a syntax error (which is now fixed).

Now I have the following code
Code: Select all
return "select (ContractSupplier1DayRate*MPANData.DayCons) AS Supplier1DayCostEst
FROM ContractData
inner join MPANData_ContractData ON ContractDataID = MPANData_ContractData.ContractDataID
inner join MPANData ON MPANData_ContractData.MPANCore = MPANData.MPANCore";

I've stripped out a lot of it to make it easier to read.

It looks like I'm in a kind of "catch 22" scenario. If I use the table name within the delegate class - like this:
Code: Select all
FROM ContractData
inner join MPANData_ContractData ON ContractData.ContractDataID = MPANData_ContractData.ContractDataID
inner join MPANData ON MPANData_ContractData.MPANCore = MPANData.MPANCore";


I get an error like this (in the browser)
Code: Select all
Error: Could not load current record: Unknown column 'ContractData.ContractDataID' in 'field list' SELECT length(`ContractData`.`Supplier1NightCostEst`) as blah blah blah

if I have this in the delegate class (i.e. ContractDataID specified *without* the tablename)
Code: Select all
FROM ContractData
inner join MPANData_ContractData ON ContractDataID = MPANData_ContractData.ContractDataID
inner join MPANData ON MPANData_ContractData.MPANCore = MPANData.MPANCore";

Code: Select all
PHP Fatal error:  Column 'ContractDataID' in on clause is ambiguous

Which is what happens on the CLI too.
Any ideas?

Cheers
cantlep
 
Posts: 172
Joined: Fri Mar 05, 2010 2:14 am

Re: PEAR_ERROR

Postby cantlep » Fri Sep 24, 2010 7:48 am

Sorted with this. (now I know why we have to alias the tables in the delegate classes ;-) ) Always learning...sorry for the load of posts.

Code: Select all
return "select c.*, (c.ContractSupplier1DayRate*m.DayCons) AS Supplier1DayCostEst
, (c.ContractSupplier1NightRate * m.NightCons) AS Supplier1NightCostEst
, (c.ContractSupplier1AddRate1 * m.AddCons1) AS Supplier1AddRate1CostEst
, (c.ContractSupplier1AddRate2 * m.AddCons2) AS Supplier1AddRate2CostEst
, (c.ContractSupplier1AddRate3 * m.AddCons3) AS Supplier1AddRate3CostEst
, (c.ContractSupplier1AddRate4 * m.AddCons4) AS Supplier1AddRate4CostEst
, (c.ContractSupplier1AddRate5 * m.AddCons5) AS Supplier1AddRate5CostEst
, (c.ContractSupplier1AddRate6 * m.AddCons6) AS Supplier1AddRate6CostEst
, (c.ContractSupplier1AddRate7 * m.AddCons7) AS Supplier1AddRate7CostEst
, (c.ContractSupplier1AddRate8 * m.AddCons8) AS Supplier1AddRate8CostEst
, (c.ContractSupplier1DayRate * m.DayCons)
+ (c.ContractSupplier1NightRate * m.NightCons)
+ (c.ContractSupplier1AddRate1 * m.AddCons1)
+ (c.ContractSupplier1AddRate2 * m.AddCons2)
+ (c.ContractSupplier1AddRate3 * m.AddCons3)
+ (c.ContractSupplier1AddRate4 * m.AddCons4)
+ (c.ContractSupplier1AddRate5 * m.AddCons5)
+ (c.ContractSupplier1AddRate6 * m.AddCons6)
+ (c.ContractSupplier1AddRate7 * m.AddCons7)
+ (c.ContractSupplier1AddRate8 * m.AddCons8) AS Supplier1TotalCostEst
FROM ContractData c
inner join MPANData_ContractData mc ON c.ContractDataID = mc.ContractDataID
inner join MPANData m ON mc.MPANCore = m.MPANCore";
cantlep
 
Posts: 172
Joined: Fri Mar 05, 2010 2:14 am


Return to Xataface Users

Who is online

Users browsing this forum: No registered users and 23 guests

cron
Powered by Dataface
© 2005-2007 Steve Hannah All rights reserved