Skip to content

Commit 8552f15

Browse files
author
Fredrick Peter
committed
Quick Fix...
1 parent 63da417 commit 8552f15

File tree

6 files changed

+48
-18
lines changed

6 files changed

+48
-18
lines changed

src/Migrations/Blueprint.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ public function handle()
119119

120120
// execute query
121121
if($this->status_runned){
122-
$this->db->query( $mysqlHandle['message'] )->execute();
122+
$this->db->dbDriver()->exec($mysqlHandle['message']);
123123
}
124124

125125
return [

src/Migrations/Traits/SchemaConfigurationTrait.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ trait SchemaConfigurationTrait{
6565
protected function addColumn($name, $type, $length = null)
6666
{
6767
$column = [
68-
'name' => $name,
69-
'type' => $type
68+
'name' => trim((string) $name),
69+
'type' => trim((string) $type)
7070
];
7171

7272
// add legnth
@@ -134,7 +134,7 @@ protected function queryForType_and_Length(?array $options = [])
134134
// for enum|set
135135
if(isset($options['values'])){
136136
array_walk($options['values'], function (&$value, $key){
137-
$value = "\'{$value}\'";
137+
$value = "'{$value}'";
138138
});
139139
$values = implode(', ', $options['values']);
140140
$columnDef .= "({$values})";
@@ -225,7 +225,7 @@ protected function queryForDefault(?array $options = [])
225225
{
226226
$columnDef = "";
227227
if (!is_null($options['default'])) {
228-
$columnDef .= " DEFAULT \'{$options['default']}\'";
228+
$columnDef .= " DEFAULT '{$options['default']}'";
229229
}
230230

231231
return $columnDef;

src/Migrations/Traits/TableStructureTrait.php

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -329,16 +329,28 @@ private function createTriggers()
329329
*/
330330
private function regixifyQuery(?string $formatted)
331331
{
332-
// Replace the comma with comma + newline
333-
$formatted = preg_replace("/,\s*/m", ",\n", $formatted);
332+
$formattedQuery = '';
333+
$indentationLevel = 0;
334+
$keywords = ['SELECT', 'FROM', 'WHERE', 'JOIN', 'GROUP BY', 'ORDER BY', 'INSERT', 'UPDATE', 'DELETE'];
335+
$lines = explode("\n", $formatted);
334336

335-
// clean string from begining and ending
336-
$formatted = preg_replace("/^[ \t]+|[ \t]+$/m", "", $formatted);
337+
foreach ($lines as $line) {
338+
$trimmedLine = trim($line);
337339

338-
// replace back-slash
339-
$formatted = str_replace('\\', '', $formatted);
340+
if (!empty($trimmedLine)) {
341+
if (in_array(strtoupper($trimmedLine), $keywords)) {
342+
$formattedQuery .= str_repeat(' ', $indentationLevel) . $trimmedLine . "\n";
343+
$indentationLevel++;
344+
} elseif ($trimmedLine === ')') {
345+
$indentationLevel--;
346+
$formattedQuery .= str_repeat(' ', $indentationLevel) . $trimmedLine . "\n";
347+
} else {
348+
$formattedQuery .= str_repeat(' ', $indentationLevel) . $trimmedLine . "\n";
349+
}
350+
}
351+
}
340352

341-
return $formatted;
353+
return $formattedQuery;
342354
}
343355

344356
}

src/Pagination/Yidas/PaginationLoader.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,8 @@ public function createUrl($page, $perPage=null)
200200
*/
201201
protected function _init()
202202
{
203+
$this->convertToIntegers();
204+
203205
// Format
204206
$this->totalCount = ($this->totalCount > 0) ? floor($this->totalCount) : 0;
205207
$this->perPage = ($this->perPage >= 1) ? floor($this->perPage) : 20;
@@ -216,4 +218,20 @@ protected function _init()
216218
// Limit ignores (total - offset)
217219
$this->limit = $this->perPage;
218220
}
221+
222+
/**
223+
* convert tp int
224+
*
225+
* @return void
226+
*/
227+
protected function convertToIntegers()
228+
{
229+
// Format
230+
$this->page = (int) $this->page;
231+
$this->perPage = (int) $this->perPage;
232+
$this->pageCount = (int) $this->pageCount;
233+
$this->totalCount = (int) $this->totalCount;
234+
}
235+
236+
219237
}

src/Query/MySqlExec.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -326,8 +326,7 @@ protected function errorTemp(Throwable|PDOException $e, $prepareQueryError = fal
326326
}
327327
}
328328

329-
dd(
330-
[
329+
return [
331330
'status' => self::ERROR_404,
332331
'message' => preg_replace(
333332
'/^[ \t]+|[ \t]+$/m', '',
@@ -338,9 +337,7 @@ protected function errorTemp(Throwable|PDOException $e, $prepareQueryError = fal
338337
<<\\PDO::ERROR>> {$e->getMessage()}
339338
"
340339
)
341-
]
342-
);
343-
exit(1);
340+
];
344341
}
345342

346343
/**

src/Traits/ReusableTrait.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,10 @@ public function autoStartDebugger()
6565
Debugger::$maxDepth = 5; // default: 3
6666
Debugger::$maxLength = 1000; // default: 150
6767
Debugger::$dumpTheme = $this->getBgColor(APP_DEBUG_BG);
68-
Debugger::enable(!APP_DEBUG);
68+
// set cookie
69+
if (!headers_sent()) {
70+
Debugger::enable(!APP_DEBUG);
71+
}
6972
}
7073
}
7174

0 commit comments

Comments
 (0)