I have one question (maybe its easy and I am just too blind).
I have a Model Address with a relation like below
'company'=>array(self::BELONGS_TO, 'Company', 'CompanyID','alias'=>'company'),
And now I want to create a query to show specific Address entries with a specific company which should be searchable e.g. search for 'mysearchcompay'.
$criteria->condition='company.Company Like '%mysearchcompany%'';
$addressList=Address::model()->with('company')->findAll($criteria);
This works like expected and also give the correct results i wanted.
But I wanted to create the search condition dynamic way with 'createSearchCondition'.
But the only way to get the right select is like below sadly the commandbuilder only accecpts the tablename or the right CMysqlTableSchema
$model=Address::model();
$schema=$model->getTableSchema();
$builder=$model->getCommandBuilder();
$relation=$model->getActiveRelation('company');
$relationclassname=$relation->className;
$tablename=CActiveRecord::model($relationclassname)->tableName();
$columns=array('0'=>'Company');
$keywords=array('0'=>'mysearchcompany');
$condition=$builder->createSearchCondition($tablename,$columns,$keywords,$prefix='company.');
will give (company.`Company` LIKE '%mysearchcompany%')
Isn't there an easy way to get to this result?
It also would be helpfull if the tablename is given in the relation.
regards Horizons

Help
This topic is locked











