bumeshrai
(Bumeshrai)
February 13, 2011, 4:08am
1
I have the following relation in model file:
' public function relations()
{
.....
'railways' => array(self::BELONGS_TO, 'Railways', 'railway'),
.. }
The table railways has a column ‘zone’.
I now modify the model search functiion thus.
public function search()
{
.....
$criteria->compare('railways.zone',$this->railway);
.. }
When I run the application I get the ‘Column not found error’ on railways.zone.
Where am I making the mistake? Thanks.
binkabir
(Binkabir)
February 13, 2011, 11:06am
2
Hello,
try this
$model=myModel::model()->search()->with(‘railways’);
this should work.
mbi
(mbi)
February 13, 2011, 1:29pm
3
$criteria->with = array('railways');
bumeshrai
(Bumeshrai)
February 14, 2011, 1:34pm
4
@Thanks mbi. Missed it!! Now works.
bumeshrai
(Bumeshrai)
February 15, 2011, 10:18am
5
.......
$criteria->with = array('railways','equipments'...);
...
for more than one related table.
temirbek
(Temirbek)
January 31, 2012, 3:39am
6
So you have a main table and Railways table with "zone" field. If you wanted to add "zone" field in the Advanced Search form (admin.php) of the main table, how would you accomplish?