$phoneModel = $this->loadMyModel(100, "PhoneNumber");
public function loadMyModel($id, $modelName){ $model = new $modelName(); $criteria = new CDbCriteria; $criteria->condition = $model->getTableAlias().".id = :id"; $criteria->params = array( "id" => $id ); $data = new CActiveDataProvider($model, array( 'criteria'=>$criteria )); if(count($data->getData()) > 0) { $data = $data->getData(); $data = $data[0]; return $data; } return null; }
Really awesome blog. Your blog is really useful for me. Thanks for sharing this informative blog. Keep update your blog.
ReplyDeleteHire Yii Developers in India