File tree Expand file tree Collapse file tree 5 files changed +49
-120
lines changed Expand file tree Collapse file tree 5 files changed +49
-120
lines changed Original file line number Diff line number Diff line change 2
2
3
3
include __DIR__ . '/../../../vendor/autoload.php ' ;
4
4
5
- $ pdo = new \PHPFUI \ORM \PDOInstance ('sqlite::memory: ' );
6
- \PHPFUI \ORM ::addConnection ($ pdo );
7
-
8
- $ lines = \file (__DIR__ . '/../../../northwind/northwind-schema.sqlite ' );
9
-
10
- $ sql = '' ;
11
-
12
- foreach ($ lines as $ line )
13
- {
14
-
15
- // Ignoring comments from the SQL script
16
- if (\str_starts_with ((string )$ line , '-- ' ) || '' == $ line )
17
- {
18
- continue ;
19
- }
20
-
21
- $ sql .= $ line ;
22
-
23
- if (\str_ends_with (\trim ((string )$ line ), '; ' ))
24
- {
25
- \PHPFUI \ORM ::execute ($ sql );
26
- $ lastError = \PHPFUI \ORM ::getLastError ();
27
-
28
- if ($ lastError )
29
- {
30
- throw new \Exception ($ lastError . ' SQL: ' . $ sql );
31
- }
32
- $ sql = '' ;
33
- }
34
- } // end foreach
5
+ $ schema = new \SOB \Schema ();
35
6
36
7
echo "Generate Record Models \n\n" ;
37
8
Original file line number Diff line number Diff line change 2
2
3
3
include __DIR__ . '/../../../vendor/autoload.php ' ;
4
4
5
- $ pdo = new \PHPFUI \ORM \PDOInstance ('sqlite::memory: ' );
6
- \PHPFUI \ORM ::addConnection ($ pdo );
7
-
8
- $ lines = \file (__DIR__ . '/../../../northwind/northwind-schema.sqlite ' );
9
-
10
- $ sql = '' ;
11
-
12
- foreach ($ lines as $ line )
13
- {
14
-
15
- // Ignoring comments from the SQL script
16
- if (\str_starts_with ((string )$ line , '-- ' ) || '' == $ line )
17
- {
18
- continue ;
19
- }
20
-
21
- $ sql .= $ line ;
22
-
23
- if (\str_ends_with (\trim ((string )$ line ), '; ' ))
24
- {
25
- \PHPFUI \ORM ::execute ($ sql );
26
- $ lastError = \PHPFUI \ORM ::getLastError ();
27
-
28
- if ($ lastError )
29
- {
30
- throw new \Exception ($ lastError . ' SQL: ' . $ sql );
31
- }
32
- $ sql = '' ;
33
- }
34
- } // end foreach
5
+ $ schema = new \SOB \Schema ();
35
6
36
7
echo "Generate Record Models \n\n" ;
37
8
Original file line number Diff line number Diff line change 2
2
3
3
include __DIR__ . '/../../../vendor/autoload.php ' ;
4
4
5
- $ pdo = new \PHPFUI \ORM \PDOInstance ('sqlite::memory: ' );
6
- \PHPFUI \ORM ::addConnection ($ pdo );
7
-
8
- $ lines = \file (__DIR__ . '/../../../northwind/northwind-schema.sqlite ' );
9
-
10
- $ sql = '' ;
11
-
12
- foreach ($ lines as $ line )
13
- {
14
-
15
- // Ignoring comments from the SQL script
16
- if (\str_starts_with ((string )$ line , '-- ' ) || '' == $ line )
17
- {
18
- continue ;
19
- }
20
-
21
- $ sql .= $ line ;
22
-
23
- if (\str_ends_with (\trim ((string )$ line ), '; ' ))
24
- {
25
- \PHPFUI \ORM ::execute ($ sql );
26
- $ lastError = \PHPFUI \ORM ::getLastError ();
27
-
28
- if ($ lastError )
29
- {
30
- throw new \Exception ($ lastError . ' SQL: ' . $ sql );
31
- }
32
- $ sql = '' ;
33
- }
34
- } // end foreach
5
+ $ schema = new \SOB \Schema ();
35
6
36
7
echo "Generate Record Models \n\n" ;
37
8
Original file line number Diff line number Diff line change 2
2
3
3
include __DIR__ . '/../../../vendor/autoload.php ' ;
4
4
5
- $ pdo = new \PHPFUI \ ORM \ PDOInstance ( ' sqlite::memory: ' );
6
- \ PHPFUI \ ORM :: addConnection ( $ pdo );
5
+ $ schema = new \SOB \ Schema ( );
6
+
7
7
\PHPFUI \ORM ::$ namespaceRoot = __DIR__ . '/../../.. ' ;
8
8
\PHPFUI \ORM ::$ recordNamespace = 'SOB\PHPFUI\Record ' ;
9
9
\PHPFUI \ORM ::$ tableNamespace = 'SOB\PHPFUI\Table ' ;
10
10
\PHPFUI \ORM ::$ migrationNamespace = 'SOB\PHPFUI\Migration ' ;
11
11
\PHPFUI \ORM ::$ idSuffix = '_id ' ;
12
12
13
- $ lines = \file (__DIR__ . '/../../../northwind/northwind-schema.sqlite ' );
14
-
15
- $ sql = '' ;
16
-
17
- foreach ($ lines as $ line )
18
- {
19
-
20
- // Ignoring comments from the SQL script
21
- if (\str_starts_with ((string )$ line , '-- ' ) || '' == $ line )
22
- {
23
- continue ;
24
- }
25
-
26
- $ sql .= $ line ;
27
-
28
- if (\str_ends_with (\trim ((string )$ line ), '; ' ))
29
- {
30
- \PHPFUI \ORM ::execute ($ sql );
31
- $ lastError = \PHPFUI \ORM ::getLastError ();
32
-
33
- if ($ lastError )
34
- {
35
- throw new \Exception ($ lastError . ' SQL: ' . $ sql );
36
- }
37
- $ sql = '' ;
38
- }
39
- } // end foreach
40
-
41
13
echo "Generate Record Models \n\n" ;
42
14
43
15
$ generator = new \PHPFUI \ORM \Tool \Generate \CRUD ();
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace SOB ;
4
+
5
+ class Schema
6
+ {
7
+
8
+ private static \PHPFUI \ORM \PDOInstance $ pdo ;
9
+
10
+ public function __construct ()
11
+ {
12
+ static ::$ pdo = new \PHPFUI \ORM \PDOInstance ('sqlite::memory: ' );
13
+ \PHPFUI \ORM ::addConnection (static ::$ pdo );
14
+
15
+ $ lines = \file (__DIR__ . '/../northwind/northwind-schema.sqlite ' );
16
+
17
+ $ sql = '' ;
18
+
19
+ foreach ($ lines as $ line )
20
+ {
21
+
22
+ // Ignoring comments from the SQL script
23
+ if (\str_starts_with ((string )$ line , '-- ' ) || '' == $ line )
24
+ {
25
+ continue ;
26
+ }
27
+
28
+ $ sql .= $ line ;
29
+
30
+ if (\str_ends_with (\trim ((string )$ line ), '; ' ))
31
+ {
32
+ \PHPFUI \ORM ::execute ($ sql );
33
+ $ lastError = \PHPFUI \ORM ::getLastError ();
34
+
35
+ if ($ lastError )
36
+ {
37
+ throw new \Exception ($ lastError . ' SQL: ' . $ sql );
38
+ }
39
+ $ sql = '' ;
40
+ }
41
+ } // end foreach
42
+ }
43
+
44
+ }
You can’t perform that action at this time.
0 commit comments