Laravel为包含所有行的单个列更新Sql

时间:2017-11-02 18:44:36

标签: php sql laravel

@ViewChild('viewerheader',{ read: ViewContainerRef }) viewerContainer;
  constructor(private dragulaService: DragulaService,private componentFactoryResolver: ComponentFactoryResolver) {
    dragulaService.drop.subscribe((value) => {
      //console.log('dropped header sunbscribed' , value ) ;
      this.onDrop(value.slice(1));

    }); 
  }

ngOnInit() { 
  this.element = document.getElementById('sectionheader0');
       console.log ('got element' ,this.element );
       $(this.element).append('<ng-template  #viewerHeader></ng-  template>');
     }
private onDrop(args) {
    let [e, target ,source,el] = args;
    this.createComponent(e.id);
  }
  
  
createComponent(id : string){
    //this.viewerContainer.clear(); 
    const factory = this.componentFactoryResolver.resolveComponentFactory(Viewer);
    const componentRef = this.viewerContainer.createComponent(factory);
    componentRef.instance.id = id;
    console.log('create Compnent called + Id' + id);
    
    console.log('create component' + id );
    } 

任何帮助将不胜感激。 这是我的数据库表。 database table (click to see the table)

1 个答案:

答案 0 :(得分:2)

您可以通过调用任何查询Builder实例末尾的更新函数来更新与特定查询匹配的所有内容。

例如,假设您要更改现在为6到7的所有siteView:

YourModelName::where('siteView', 6)->update(['siteView' => 7]);

如果您想要更新所有行,您还可以直接调用update on :: query:

YourModelName::query()->update(['siteView' => 8]);

您可以在此处详细了解此更新功能: https://laravel.com/docs/5.5/eloquent#updates