0
votes

I upgraded my application from Koahana 3.0.1 to Kohana 3.3. It works correctly in Koahana 3.0.1. But, in Kohana 3.3, I'm getting unknown column error. Below is the query I'm using in business model.

$biz = $this->where('business.id','IN',$arr)
       ->join('users','LEFT') 
   ->select(array('users.id','u'))
   ->on('users.business_id','=','business.id')  
   ->find_all();

The table names are businesses and users. The model is defined as

class Model_Business extends ORM  

The error says -

Database_Exception [ 1054 ]: Unknown column 'businesses.id' in 'where clause'

I could fix this(by updating as above) but, now new error I got is - "Method find() cannot be called on loaded objects".

It looks we can not use find_all() in model itself. In my current project, we return the results from model for all the queries. That means, upgrading will need to change almost all code. Is there any workaround for this ?

2
Please post the full error message. - laurent
looks like your businesses -> business alias is causing the problem for some reason - danjp

2 Answers

0
votes

Have you tried it with businesses.id?

0
votes

Since Kohana 3.1, the ORM fields always return the alias name. If it's a $_has_many, it's plural, if it's a $_has_one or $_belongs_to, it's singular. If you want to ensure the model name, set $_object_name to your desired value