SqlHelper.php 422 B

1234567891011121314151617181920212223
  1. <?php
  2. namespace common\util;
  3. use yii\db\ActiveRecord;
  4. class SqlHelper
  5. {
  6. /**
  7. * @param $paramData
  8. * @param ActiveRecord $model
  9. */
  10. public static function setAttributeFromParamData(ActiveRecord $model, $paramData)
  11. {
  12. foreach ($paramData as $key => $value) {
  13. if ($model->hasAttribute($key)) {
  14. $model->setAttribute($key, $value);
  15. }
  16. }
  17. }
  18. }