console

http://laravel.com/

http://kejyun.github.io/Laravel-4-Docum ... roduction/
回覆文章
yehlu
Site Admin
文章: 3245
註冊時間: 2004-04-15 17:20:21
來自: CodeCharge Support Engineer

console

文章 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,
    ];
回覆文章

回到「laravel」