Subversion-Projekte lars-tiefland.laravel_shop

Revision

Revision 241 | Revision 243 | Zur aktuellen Revision | Details | Vergleich mit vorheriger | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
233 lars 1
<?php
2
 
3
namespace App\Console\Commands;
4
 
5
use Illuminate\Console\Command;
236 lars 6
use Illuminate\Support\Facades\DB;
233 lars 7
 
8
class convertDB extends Command
9
{
10
    /**
11
     * The name and signature of the console command.
12
     *
13
     * @var string
14
     */
235 lars 15
    protected $signature = 'command:convertDB';
233 lars 16
 
17
    /**
18
     * The console command description.
19
     *
20
     * @var string
21
     */
235 lars 22
    protected $description = 'Converts the old webanOS-DB to laravel';
233 lars 23
 
24
    /**
25
     * Execute the console command.
26
     *
27
     * @return int
28
     */
29
    public function handle()
30
    {
234 lars 31
        $sql = '
32
            SELECT
33
                *
34
            FROM
35
                directory
36
            WHERE
37
                father>=-1
38
        ';
237 lars 39
        $dirs = DB::connection('old')->select($sql);
238 lars 40
        foreach ($dirs as $row)
41
        {
42
            //var_dump($row);
43
            DB::table('directories')->insertOrIgnore([
239 lars 44
                "id"           => $row->ID,
45
                "directory_id" => $row->Father,
240 lars 46
                "name"         => $row->Name,
239 lars 47
                "status"       => $row->status,
241 lars 48
                "kennung"      => $row->Kennung,
242 lars 49
                "description"  => $row->Beschreibung,
239 lars 50
                "short_line_1" => $row->short_line_1,
51
                "url"          => $row->url,
241 lars 52
                "created_at"   => $row["erstellt_am"],
53
                "updated_at"   => $row["letzte_Aenderung_am"],
238 lars 54
            ]);
234 lars 55
        }
233 lars 56
    }
57
}