Subversion-Projekte lars-tiefland.laravel_shop

Revision

Revision 237 | Revision 239 | 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([
44
                "id"           => $row["ID"],
45
                "directory_id" => $row["Father"],
46
                "name"         => $row["name"],
47
                "status"       => $row["status"],
48
                "kennung"      => $row["kennung"],
49
                "description"  => $row["beschreibung"],
50
                "short_line_1" => $row["short_line_1"],
51
                "url"          => $row["url"],
52
            ]);
234 lars 53
        }
233 lars 54
    }
55
}