Suppose your model name is “CompanyUnit”. Now you want to select data from there using PrimaryKey(PK). Then you can use “findByPk()” method in yiiframe. It is very easy and simple to use.
- $comUnit = CompanyUnit::model()->findByPk(2);
- echo $comUnit->name;
Here “2″ is a PK and “CompanyUnit” is a name of model.
when “echo $comUnit->name” is executed then display name base of pk.
I think you like that.