cascade relation in a table

here the table is defined as following:

table category (

cat_id smallint(5) unsigned NOT NULL auto_increment,

cat_name varchar(90) NOT NULL default ‘’,

keywords varchar(255) NOT NULL default ‘’,

cat_desc varchar(255) NOT NULL default ‘’,

parent_id smallint(5) unsigned NOT NULL default ‘0’,

sort_order tinyint(1) unsigned NOT NULL default ‘0’,

is_leaf tinyint(1) unsigned NOT NULL default ‘0’,

template_file varchar(50) NOT NULL default ‘’,

measure_unit varchar(15) NOT NULL default ‘’,

show_in_nav tinyint(1) NOT NULL default ‘0’,

PRIMARY KEY (cat_id),

KEY parent_id (parent_id)

) TYPE=MyISAM;

in AR class Category.php

public function relations()


{


	return array(


		'childrenCates'=>array(self::HAS_MANY, 'Category', 'childrenCates.parent_id'),


	);


}

But, in controller code:

	$criteria = new CDbCriteria;


	$criteria->select = 'cat_id,cat_name';


	$criteria->condition = 'parent_id=:parentId';


	$criteria->params = array(':parentId'=>0);


	$criteria->order = 'cat_id ASC';


	$cates = Category::model()->with('childrenCates')->findAll($criteria);

An exception is return:

The relation "childrenCates" in active record class "Category" is specified with an invalid foreign key "childrenCates.parent_id". There is no such column in the table "category".

Thanks for your any help.

I think the correct one will be:




public function relations()

{

return array(

'childrenCates'=>array(self::HAS_MANY, 'Categories', 'parent_id'),

);