Skip to content

Commit 137e11e

Browse files
authoredNov 29, 2024
Merge pull request #36 from PhpSlides/dev
fixes error
2 parents 5e8436f + ea2b286 commit 137e11e

File tree

2 files changed

+14
-11
lines changed

2 files changed

+14
-11
lines changed
 

‎src/Forgery/Forge.php

+13-10
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ protected static function table($db_name)
6868
$class = str_replace(
6969
'App\\',
7070
'',
71-
implode('\\', $all_names) . '\\' . $table_name
71+
implode('\\', $all_names) . '\\' . $table_name,
7272
);
7373

7474
# Drop Table
@@ -90,7 +90,7 @@ protected static function table($db_name)
9090
if ($table_name != 'options.sql') {
9191
static::log(
9292
'WARNING',
93-
"Ignored Table `$table_name` in `$db_name` Database."
93+
"Ignored Table `$table_name` in `$db_name` Database.",
9494
);
9595
}
9696
continue;
@@ -102,7 +102,7 @@ protected static function table($db_name)
102102
$query = DB::query(
103103
'SELECT * FROM information_schema.tables WHERE table_schema=%s AND table_name=%s',
104104
$db_name,
105-
$table_name
105+
$table_name,
106106
);
107107

108108
if (!empty($query)) {
@@ -121,18 +121,21 @@ protected static function table($db_name)
121121
'REFERENCES' => null,
122122
'DELETE' => null,
123123
'UPDATE' => null,
124-
'OTHERS' => null
124+
'OTHERS' => null,
125125
];
126126

127-
$db_columns = array_keys(DB::columnList($table_name));
127+
$db_columns = [];
128+
if ($table_already_exists) {
129+
$db_columns = array_keys(DB::columnList($table_name));
130+
}
128131

129132
/**
130133
* Filter the array, if the column already exists in the database
131134
* then remove it from the array of columns that will be created.
132135
*/
133136
$filePath = array_filter($filePath, function ($path) use (
134137
$table_already_exists,
135-
$db_columns
138+
$db_columns,
136139
) {
137140
if ($table_already_exists) {
138141
$column_name = self::get_column_name($path);
@@ -166,7 +169,7 @@ protected static function table($db_name)
166169
column_name: $columns[$i][0],
167170
path: $columns[$i][1],
168171
constraint: $constraint,
169-
table_name: $table_name
172+
table_name: $table_name,
170173
);
171174
$query[] = $res[0];
172175
$constraint = $res[1];
@@ -240,20 +243,20 @@ protected static function table($db_name)
240243
DB::query("ALTER TABLE $table_name $query");
241244
static::log(
242245
'INFO',
243-
"Altered Table `$table_name` and adds column `$only_columns`"
246+
"Altered Table `$table_name` and adds column `$only_columns`",
244247
);
245248
} else {
246249
DB::query("CREATE TABLE $table_name ($query)");
247250
static::log(
248251
'INFO',
249-
"Created Table `$table_name` in `$db_name` Database"
252+
"Created Table `$table_name` in `$db_name` Database",
250253
);
251254
}
252255
}
253256
} catch (\Exception $e) {
254257
static::log(
255258
'ERROR',
256-
"Unable to create Table `$table_name` in `$db_name` Database. [Exception]: {$e->getMessage()}"
259+
"Unable to create Table `$table_name` in `$db_name` Database. [Exception]: {$e->getMessage()}",
257260
);
258261
return;
259262
}

‎src/Globals/Functions.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
use PhpSlides\Loader\FileLoader;
77
use PhpSlides\Foundation\Application;
88

9-
define('__ROOT__', Application::$basePath);
9+
putenv(sprintf('__DIR__=%s', Application::$basePath));
1010

1111
const GET = 'GET';
1212
const PUT = 'PUT';

0 commit comments

Comments
 (0)