Thanks for the response, but I still get the same error. It's like the TradingAccountsTradingSystem model just can't be seen from anywhere except it's own controller...
Does anyone know if these join models need to be handled differently somehow? It appears that they do, but what needs to be done? Thanks, Rob On Feb 16, 6:35 pm, brian <[email protected]> wrote: > I believe you need to call it like this > > $this->controller->TradingAccount->TradingAccountsTradingSystem->getSystemUsePercent(); > > Although, I'd probably create a method in TradingAccount that then > called out to the other model. > > $this->controller->TradingAccount->getSUP(); > > function getSUP() > { > return $this->TATS->getSUP(); > > } > On Mon, Feb 16, 2009 at 6:31 PM, rob_page <[email protected]> wrote: > > > Hello, > > > I hope that someone can help me with this very odd problem. I'm > > trying to call a custom model function, and I keep getting the > > following error: > > > SQL Error: 1064: You have an error in your SQL syntax; > > Query: getSystemUsePercent > > > Now, I'm using custom model functions in many other places in my > > application, but this one is different in that the model is for a > > hasAndBelongsToMany relationship (model is > > TradingAccountsTradingSystem). > > > The relationships in TradingAccountsTradingSystem model are > > var $belongsTo = array( > > 'TradingAccount' => array('className' => > > 'TradingAccount', > > 'foreignKey' => > > 'trading_account_id', > > 'conditions' => '', > > 'fields' => '', > > 'order' => '' > > ), > > 'TradingSystem' => array('className' => > > 'TradingSystem', > > 'foreignKey' => > > 'trading_system_id', > > 'conditions' => '', > > 'fields' => '', > > 'order' => '' > > ) > > ); > > > The function 'getSystemUsePercent' IS declared in the > > TradingAccountsTradingSystem model. > > > I'm calling the function from a component as follows: > > $this->controller->TradingAccountsTradingSystem->getSystemUsePercent > > (); > > I've verified that the controller I'm calling the component from > > 'uses' TradingAccountsTradingSystem. In this case it's the > > TradingAccountsController. > > > In the past when I've gotten this SQL error, the problem has made > > sense - usually I've missed adding the appropriate controller to the > > 'uses' array. But this one doesn't make sense. I'm not sure what else > > I need to do. Am I not supposed to be able to make these kinds of > > calls to the hasAndBelongsToMany join model? > > > Thanks for any help. > > > Rob Page > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---
