Subversion-Projekte lars-tiefland.laravel_shop

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
148 lars 1
<?php
2
 
3
namespace Illuminate\Database\Schema;
4
 
5
use Illuminate\Support\Facades\File;
6
 
7
class SQLiteBuilder extends Builder
8
{
9
    /**
10
     * Create a database in the schema.
11
     *
12
     * @param  string  $name
13
     * @return bool
14
     */
15
    public function createDatabase($name)
16
    {
17
        return File::put($name, '') !== false;
18
    }
19
 
20
    /**
21
     * Drop a database from the schema if the database exists.
22
     *
23
     * @param  string  $name
24
     * @return bool
25
     */
26
    public function dropDatabaseIfExists($name)
27
    {
28
        return File::exists($name)
29
            ? File::delete($name)
30
            : true;
31
    }
32
 
33
    /**
34
     * Drop all tables from the database.
35
     *
36
     * @return void
37
     */
38
    public function dropAllTables()
39
    {
40
        if ($this->connection->getDatabaseName() !== ':memory:') {
41
            return $this->refreshDatabaseFile();
42
        }
43
 
44
        $this->connection->select($this->grammar->compileEnableWriteableSchema());
45
 
46
        $this->connection->select($this->grammar->compileDropAllTables());
47
 
48
        $this->connection->select($this->grammar->compileDisableWriteableSchema());
49
 
50
        $this->connection->select($this->grammar->compileRebuild());
51
    }
52
 
53
    /**
54
     * Drop all views from the database.
55
     *
56
     * @return void
57
     */
58
    public function dropAllViews()
59
    {
60
        $this->connection->select($this->grammar->compileEnableWriteableSchema());
61
 
62
        $this->connection->select($this->grammar->compileDropAllViews());
63
 
64
        $this->connection->select($this->grammar->compileDisableWriteableSchema());
65
 
66
        $this->connection->select($this->grammar->compileRebuild());
67
    }
68
 
69
    /**
70
     * Get all of the table names for the database.
71
     *
72
     * @return array
73
     */
74
    public function getAllTables()
75
    {
76
        return $this->connection->select(
77
            $this->grammar->compileGetAllTables()
78
        );
79
    }
80
 
81
    /**
82
     * Get all of the view names for the database.
83
     *
84
     * @return array
85
     */
86
    public function getAllViews()
87
    {
88
        return $this->connection->select(
89
            $this->grammar->compileGetAllViews()
90
        );
91
    }
92
 
93
    /**
94
     * Empty the database file.
95
     *
96
     * @return void
97
     */
98
    public function refreshDatabaseFile()
99
    {
100
        file_put_contents($this->connection->getDatabaseName(), '');
101
    }
102
}