1 頁 (共 1 頁)

console

發表於 : 2017-03-12 15:25:23
yehlu
https://laravel.com/docs/5.3/artisan

app/Console/Commands/UploadXml.php

代碼: 選擇全部

<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;
use DB;

class UploadXML extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'UploadXml';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Command description';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {
        //
        $inv  = DB::select('select * from inv_heads where status = "" order by id limit 0,1');
        //dd($inv);
        foreach($inv as $key => $value){
          //dd($value);
          $effect = DB::update('update  inv_heads set status = 1 where id = '.$value->id);
          if($effect){
            echo "updated successfully \n";
          }else{
            echo "nothing effects \n";
          }
        }
    }
}

app/Console/Kernel.php

代碼: 選擇全部

    protected $commands = [
        \App\Console\Commands\UploadXml::class,
    ];