Subversion-Projekte lars-tiefland.laravel_shop

Revision

Revision 237 | Revision 239 | Zur aktuellen Revision | Blame | Vergleich mit vorheriger | Letzte Änderung | Log anzeigen | RSS feed

<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;

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

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Converts the old webanOS-DB to laravel';

    /**
     * Execute the console command.
     *
     * @return int
     */
    public function handle()
    {
        $sql = '
            SELECT 
                *
            FROM
                directory
            WHERE
                father>=-1
        ';
        $dirs = DB::connection('old')->select($sql);
        foreach ($dirs as $row)
        {
            //var_dump($row);
            DB::table('directories')->insertOrIgnore([
                "id"           => $row["ID"],
                "directory_id" => $row["Father"],
                "name"         => $row["name"],
                "status"       => $row["status"],
                "kennung"      => $row["kennung"],
                "description"  => $row["beschreibung"],
                "short_line_1" => $row["short_line_1"],
                "url"          => $row["url"],
            ]);
        }
    }
}