@@ -38,19 +38,19 @@ discard block |
||
38 | 38 | * Optional. Chat invite link, which was used by the user to join the chat; for joining by invite link events |
39 | 39 | * only. |
40 | 40 | */ |
41 | - public null|chatInviteLink $invite_link = null; |
|
41 | + public null | chatInviteLink $invite_link = null; |
|
42 | 42 | |
43 | 43 | /** |
44 | 44 | * Optional. True, if the user joined the chat after sending a direct join request without using an invite link |
45 | 45 | * and being approved by an administrator |
46 | 46 | */ |
47 | - public null|bool $via_join_request = null; |
|
47 | + public null | bool $via_join_request = null; |
|
48 | 48 | |
49 | 49 | /** Optional. True, if the user joined the chat via a chat folder invite link */ |
50 | - public null|bool $via_chat_folder_invite_link = null; |
|
50 | + public null | bool $via_chat_folder_invite_link = null; |
|
51 | 51 | |
52 | 52 | |
53 | - public function __construct(stdClass|null $object = null) { |
|
53 | + public function __construct(stdClass | null $object = null) { |
|
54 | 54 | if ($object != null) { |
55 | 55 | parent::__construct($object, self::subs); |
56 | 56 | } |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | * |
80 | 80 | * @return bool |
81 | 81 | */ |
82 | - public function isMe (): bool { |
|
82 | + public function isMe(): bool { |
|
83 | 83 | return $this->new_chat_member->user->id == settings::$bot_id; |
84 | 84 | } |
85 | 85 | |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | * |
116 | 116 | * @return bool |
117 | 117 | */ |
118 | - public function isLeaved (): bool { |
|
118 | + public function isLeaved(): bool { |
|
119 | 119 | return $this->new_chat_member->status === chatMemberStatus::LEFT; |
120 | 120 | } |
121 | 121 | |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | * |
125 | 125 | * @return bool |
126 | 126 | */ |
127 | - public function isKicked (): bool { |
|
127 | + public function isKicked(): bool { |
|
128 | 128 | return $this->new_chat_member->status === chatMemberStatus::KICKED; |
129 | 129 | } |
130 | 130 | |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | * |
134 | 134 | * @return bool |
135 | 135 | */ |
136 | - public function isOldAdmin (): bool { |
|
136 | + public function isOldAdmin(): bool { |
|
137 | 137 | return $this->old_chat_member->status === chatMemberStatus::ADMINISTRATOR; |
138 | 138 | } |
139 | 139 | |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | * |
143 | 143 | * @return bool |
144 | 144 | */ |
145 | - public function isNewAdmin (): bool { |
|
145 | + public function isNewAdmin(): bool { |
|
146 | 146 | return $this->new_chat_member->status === chatMemberStatus::ADMINISTRATOR; |
147 | 147 | } |
148 | 148 | } |
@@ -30,12 +30,12 @@ discard block |
||
30 | 30 | /** |
31 | 31 | * If you want to use it in standalone mode , you MUST set `auto_process` to `false` |
32 | 32 | */ |
33 | - public static function init (string $host = 'localhost', string $username = 'root', string $password = '', string $dbname = '', bool $auto_process = true, int $port = 3306, bool $auto_load = false): void { |
|
33 | + public static function init(string $host = 'localhost', string $username = 'root', string $password = '', string $dbname = '', bool $auto_process = true, int $port = 3306, bool $auto_load = false): void { |
|
34 | 34 | self::$auto_process = $auto_process; |
35 | 35 | self::$db_name = $dbname; |
36 | 36 | self::$connection = new mysqli($host, $username, $password, $dbname, $port); |
37 | 37 | if (self::$connection->connect_errno) { |
38 | - logger::write('SQL connection has problem : ' . self::$connection->connect_error, loggerTypes::ERROR); |
|
38 | + logger::write('SQL connection has problem : '.self::$connection->connect_error, loggerTypes::ERROR); |
|
39 | 39 | throw new bptException('SQL_CONNECTION_PROBLEM'); |
40 | 40 | } |
41 | 41 | |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | } |
45 | 45 | } |
46 | 46 | |
47 | - private static function install (bool $auto_load): void { |
|
47 | + private static function install(bool $auto_load): void { |
|
48 | 48 | if (self::$auto_process) { |
49 | 49 | self::pureQuery(" |
50 | 50 | CREATE TABLE `users` |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | foreach ($allowed_file_names as $allowed_file_name) { |
81 | 81 | if (file_exists($allowed_file_name)) { |
82 | 82 | $mysqli->multi_query(file_get_contents($allowed_file_name)); |
83 | - while ($mysqli->next_result()){if (!$mysqli->more_results()) break;} |
|
83 | + while ($mysqli->next_result()) {if (!$mysqli->more_results()) break; } |
|
84 | 84 | $loaded = true; |
85 | 85 | } |
86 | 86 | } |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | /** |
95 | 95 | * @internal Only for BPT self usage , Don't use it in your source! |
96 | 96 | */ |
97 | - public static function process (): void { |
|
97 | + public static function process(): void { |
|
98 | 98 | if (self::$auto_process) { |
99 | 99 | if (isset(BPT::$update->message)) { |
100 | 100 | self::processMessage(BPT::$update->message); |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | } |
115 | 115 | } |
116 | 116 | |
117 | - private static function processMessage (message $update): void { |
|
117 | + private static function processMessage(message $update): void { |
|
118 | 118 | $type = $update->chat->type; |
119 | 119 | if ($type === chatType::PRIVATE) { |
120 | 120 | $user_id = $update->from->id; |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | } |
141 | 141 | } |
142 | 142 | |
143 | - private static function processCallbackQuery (callbackQuery $update): void { |
|
143 | + private static function processCallbackQuery(callbackQuery $update): void { |
|
144 | 144 | $type = $update->message->chat->type; |
145 | 145 | if ($type === chatType::PRIVATE) { |
146 | 146 | $user_id = $update->from->id; |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | } |
151 | 151 | } |
152 | 152 | |
153 | - private static function processInlineQuery (inlineQuery $update): void { |
|
153 | + private static function processInlineQuery(inlineQuery $update): void { |
|
154 | 154 | $type = $update->chat_type; |
155 | 155 | if ($type === chatType::PRIVATE || $type === chatType::SENDER) { |
156 | 156 | $user_id = $update->from->id; |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | } |
161 | 161 | } |
162 | 162 | |
163 | - private static function processMyChatMember (chatMemberUpdated $update): void { |
|
163 | + private static function processMyChatMember(chatMemberUpdated $update): void { |
|
164 | 164 | $type = $update->chat->type; |
165 | 165 | if ($type === chatType::PRIVATE) { |
166 | 166 | if ($update->new_chat_member->status === chatMemberStatus::MEMBER) { |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | * |
184 | 184 | * @return bool |
185 | 185 | */ |
186 | - public static function addDefaultWhere (array $where): bool { |
|
186 | + public static function addDefaultWhere(array $where): bool { |
|
187 | 187 | if (empty(self::$default_where)) { |
188 | 188 | self::$default_where = $where; |
189 | 189 | } |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | * |
199 | 199 | * @return mysqli |
200 | 200 | */ |
201 | - public static function getMysqli (): mysqli|false { |
|
201 | + public static function getMysqli(): mysqli | false { |
|
202 | 202 | return self::$connection ?? false; |
203 | 203 | } |
204 | 204 | |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | * |
210 | 210 | * @return int|string |
211 | 211 | */ |
212 | - public static function affected_rows (): int|string { |
|
212 | + public static function affected_rows(): int | string { |
|
213 | 213 | return self::$connection->affected_rows; |
214 | 214 | } |
215 | 215 | |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | * |
221 | 221 | * @return int|string |
222 | 222 | */ |
223 | - public static function affectedRows (): int|string { |
|
223 | + public static function affectedRows(): int | string { |
|
224 | 224 | return self::$connection->affected_rows; |
225 | 225 | } |
226 | 226 | |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | * |
232 | 232 | * @return int|string |
233 | 233 | */ |
234 | - public static function insert_id (): int|string { |
|
234 | + public static function insert_id(): int | string { |
|
235 | 235 | return self::$connection->insert_id; |
236 | 236 | } |
237 | 237 | |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | * |
243 | 243 | * @return int|string |
244 | 244 | */ |
245 | - public static function insertId (): int|string { |
|
245 | + public static function insertId(): int | string { |
|
246 | 246 | return self::$connection->insert_id; |
247 | 247 | } |
248 | 248 | |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | * |
254 | 254 | * @return string |
255 | 255 | */ |
256 | - public static function escapeString (string $text): string { |
|
256 | + public static function escapeString(string $text): string { |
|
257 | 257 | return self::$connection->real_escape_string($text); |
258 | 258 | } |
259 | 259 | |
@@ -262,7 +262,7 @@ discard block |
||
262 | 262 | * |
263 | 263 | * @return string |
264 | 264 | */ |
265 | - public static function error (): string { |
|
265 | + public static function error(): string { |
|
266 | 266 | return self::$connection->error; |
267 | 267 | } |
268 | 268 | |
@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | * |
272 | 272 | * @return int |
273 | 273 | */ |
274 | - public static function errno (): int { |
|
274 | + public static function errno(): int { |
|
275 | 275 | return self::$connection->errno; |
276 | 276 | } |
277 | 277 | |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | * |
283 | 283 | * @return bool |
284 | 284 | */ |
285 | - public static function setCharset (string $charset): bool { |
|
285 | + public static function setCharset(string $charset): bool { |
|
286 | 286 | return self::$connection->set_charset($charset); |
287 | 287 | } |
288 | 288 | |
@@ -297,7 +297,7 @@ discard block |
||
297 | 297 | * |
298 | 298 | * @return mysqli_result|bool |
299 | 299 | */ |
300 | - public static function pureQuery (string $query): mysqli_result|bool { |
|
300 | + public static function pureQuery(string $query): mysqli_result | bool { |
|
301 | 301 | return self::$connection->query($query); |
302 | 302 | } |
303 | 303 | |
@@ -318,7 +318,7 @@ discard block |
||
318 | 318 | * |
319 | 319 | * @return mysqli_result|bool |
320 | 320 | */ |
321 | - public static function query (string $query, array $vars = [], bool $need_result = true): mysqli_result|bool { |
|
321 | + public static function query(string $query, array $vars = [], bool $need_result = true): mysqli_result | bool { |
|
322 | 322 | if (empty($vars)) { |
323 | 323 | return self::pureQuery($query); |
324 | 324 | } |
@@ -335,7 +335,7 @@ discard block |
||
335 | 335 | $types .= 's'; |
336 | 336 | } |
337 | 337 | } |
338 | - $prepare->bind_param($types,...$vars); |
|
338 | + $prepare->bind_param($types, ...$vars); |
|
339 | 339 | if (!$prepare->execute()) { |
340 | 340 | logger::write(loggerTypes::WARNING, $prepare->error); |
341 | 341 | return false; |
@@ -382,8 +382,8 @@ discard block |
||
382 | 382 | else { |
383 | 383 | $query .= ' AND'; |
384 | 384 | } |
385 | - $operator = substr($sub_value,0,2); |
|
386 | - $operator_value = substr($sub_value,2); |
|
385 | + $operator = substr($sub_value, 0, 2); |
|
386 | + $operator_value = substr($sub_value, 2); |
|
387 | 387 | switch ($operator) { |
388 | 388 | case '>=': |
389 | 389 | $query .= " `$name` >= ?"; |
@@ -410,8 +410,8 @@ discard block |
||
410 | 410 | $sub_value = $operator_value; |
411 | 411 | break; |
412 | 412 | case '##': |
413 | - $operator = substr($operator_value,0,2); |
|
414 | - $column = substr($operator_value,2); |
|
413 | + $operator = substr($operator_value, 0, 2); |
|
414 | + $column = substr($operator_value, 2); |
|
415 | 415 | $query .= match ($operator) { |
416 | 416 | '>=' => " `$name` >= `$column`", |
417 | 417 | '<=' => " `$name` <= `$column`", |
@@ -435,17 +435,17 @@ discard block |
||
435 | 435 | return $values; |
436 | 436 | } |
437 | 437 | |
438 | - private static function groupByBuilder(string &$query, string|array $group_by = []): void { |
|
438 | + private static function groupByBuilder(string &$query, string | array $group_by = []): void { |
|
439 | 439 | if (empty($group_by)) { |
440 | 440 | return; |
441 | 441 | } |
442 | 442 | if (is_string($group_by)) { |
443 | 443 | $group_by = [$group_by]; |
444 | 444 | } |
445 | - $query .= ' GROUP BY `' . implode('`, `',$group_by) . '`'; |
|
445 | + $query .= ' GROUP BY `'.implode('`, `', $group_by).'`'; |
|
446 | 446 | } |
447 | 447 | |
448 | - private static function orderByBuilder(string &$query, string|array $order_by = []): void { |
|
448 | + private static function orderByBuilder(string &$query, string | array $order_by = []): void { |
|
449 | 449 | if (empty($order_by)) { |
450 | 450 | return; |
451 | 451 | } |
@@ -498,8 +498,8 @@ discard block |
||
498 | 498 | continue; |
499 | 499 | } |
500 | 500 | |
501 | - $operator = substr($value,0,2); |
|
502 | - $operator_value = substr($value,2); |
|
501 | + $operator = substr($value, 0, 2); |
|
502 | + $operator_value = substr($value, 2); |
|
503 | 503 | switch ($operator) { |
504 | 504 | case '+=': |
505 | 505 | $query .= " `$name` = `$name` + ?"; |
@@ -532,14 +532,14 @@ discard block |
||
532 | 532 | return $values; |
533 | 533 | } |
534 | 534 | |
535 | - private static function insertBuilder(string &$query, string|array $columns, array|string $values): array { |
|
536 | - $query .= '(`' . (is_string($columns) ? $columns : implode('`, `', $columns)) . '`) VALUES ('; |
|
535 | + private static function insertBuilder(string &$query, string | array $columns, array | string $values): array { |
|
536 | + $query .= '(`'.(is_string($columns) ? $columns : implode('`, `', $columns)).'`) VALUES ('; |
|
537 | 537 | if (is_string($values)) $values = [$values]; |
538 | - $query .= '?' . str_repeat(', ?', count($values) - 1) . ')'; |
|
538 | + $query .= '?'.str_repeat(', ?', count($values) - 1).')'; |
|
539 | 539 | return $values; |
540 | 540 | } |
541 | 541 | |
542 | - private static function selectBuilder (string &$query, string|array $columns): void { |
|
542 | + private static function selectBuilder(string &$query, string | array $columns): void { |
|
543 | 543 | if ($columns == '*') { |
544 | 544 | $query .= ' * '; |
545 | 545 | return; |
@@ -558,7 +558,7 @@ discard block |
||
558 | 558 | $formatted = '*'; |
559 | 559 | $column = 'all'; |
560 | 560 | } |
561 | - $query .= strtoupper($function) . "($formatted) as `{$function}_$column`"; |
|
561 | + $query .= strtoupper($function)."($formatted) as `{$function}_$column`"; |
|
562 | 562 | } |
563 | 563 | else { |
564 | 564 | $query .= "`$column`"; |
@@ -584,7 +584,7 @@ discard block |
||
584 | 584 | * |
585 | 585 | * @return bool |
586 | 586 | */ |
587 | - public static function delete (string $table, array $where = [], int $count = null, int $offset = null, bool $ignore_default_where = false): bool { |
|
587 | + public static function delete(string $table, array $where = [], int $count = null, int $offset = null, bool $ignore_default_where = false): bool { |
|
588 | 588 | $query = "DELETE FROM `$table`"; |
589 | 589 | $vars = self::whereBuilder($query, $where, $ignore_default_where); |
590 | 590 | self::countBuilder($query, $count, $offset); |
@@ -605,7 +605,7 @@ discard block |
||
605 | 605 | * |
606 | 606 | * @return bool |
607 | 607 | */ |
608 | - public static function update (string $table, array $modify, array $where = [], int $count = null, int $offset = null, bool $ignore_default_where = false): bool { |
|
608 | + public static function update(string $table, array $modify, array $where = [], int $count = null, int $offset = null, bool $ignore_default_where = false): bool { |
|
609 | 609 | $query = "UPDATE `$table` SET"; |
610 | 610 | $modify_vars = self::updateBuilder($query, $modify); |
611 | 611 | $where_vars = self::whereBuilder($query, $where, $ignore_default_where); |
@@ -624,7 +624,7 @@ discard block |
||
624 | 624 | * |
625 | 625 | * @return bool |
626 | 626 | */ |
627 | - public static function insert (string $table, string|array $columns, array|string $values): bool { |
|
627 | + public static function insert(string $table, string | array $columns, array | string $values): bool { |
|
628 | 628 | $query = "INSERT INTO `$table`"; |
629 | 629 | $values = self::insertBuilder($query, $columns, $values); |
630 | 630 | return self::query($query, $values, false); |
@@ -640,7 +640,7 @@ discard block |
||
640 | 640 | * |
641 | 641 | * @return bool |
642 | 642 | */ |
643 | - public static function multiInsert (string $table, array ...$inserts): bool { |
|
643 | + public static function multiInsert(string $table, array ...$inserts): bool { |
|
644 | 644 | $all_letters = true; |
645 | 645 | foreach ($inserts as $insert) { |
646 | 646 | foreach ($insert as $column => $value) { |
@@ -654,7 +654,7 @@ discard block |
||
654 | 654 | if ($all_letters) { |
655 | 655 | sort($columns); |
656 | 656 | } |
657 | - $query = "INSERT INTO `$table`(`" . '' . (is_string($columns) ? $columns : implode('`, `', $columns)) . '`) VALUES'; |
|
657 | + $query = "INSERT INTO `$table`(`".''.(is_string($columns) ? $columns : implode('`, `', $columns)).'`) VALUES'; |
|
658 | 658 | |
659 | 659 | $all_values = []; |
660 | 660 | foreach ($inserts as $key => $insert) { |
@@ -662,7 +662,7 @@ discard block |
||
662 | 662 | asort($insert); |
663 | 663 | } |
664 | 664 | $values = array_values($insert); |
665 | - $query .= ($key != 0 ? ',' : '') . ' (?' . str_repeat(', ?', count($values) - 1) . ')'; |
|
665 | + $query .= ($key != 0 ? ',' : '').' (?'.str_repeat(', ?', count($values) - 1).')'; |
|
666 | 666 | $all_values = array_merge($all_values, $values); |
667 | 667 | } |
668 | 668 | return self::query($query, $all_values, false); |
@@ -685,7 +685,7 @@ discard block |
||
685 | 685 | * |
686 | 686 | * @return bool |
687 | 687 | */ |
688 | - public static function insertUpdate (string $table, string|array $columns, array|string $values, array $modify): bool { |
|
688 | + public static function insertUpdate(string $table, string | array $columns, array | string $values, array $modify): bool { |
|
689 | 689 | $query = "INSERT INTO `$table`"; |
690 | 690 | $values = self::insertBuilder($query, $columns, $values); |
691 | 691 | $query .= ' ON DUPLICATE KEY UPDATE'; |
@@ -711,14 +711,14 @@ discard block |
||
711 | 711 | * |
712 | 712 | * @return mysqli_result|bool |
713 | 713 | */ |
714 | - public static function select (string $table, array|string $columns = '*', array $where = [], int $count = null, int $offset = null, array|string $group_by = [], array|string $order_by = [], bool $ignore_default_where = false): mysqli_result|bool { |
|
714 | + public static function select(string $table, array | string $columns = '*', array $where = [], int $count = null, int $offset = null, array | string $group_by = [], array | string $order_by = [], bool $ignore_default_where = false): mysqli_result | bool { |
|
715 | 715 | $query = 'SELECT'; |
716 | 716 | self::selectBuilder($query, $columns); |
717 | 717 | $query .= "FROM `$table`"; |
718 | - $var = self::whereBuilder($query,$where, $ignore_default_where); |
|
718 | + $var = self::whereBuilder($query, $where, $ignore_default_where); |
|
719 | 719 | self::groupByBuilder($query, $group_by); |
720 | 720 | self::orderByBuilder($query, $order_by); |
721 | - self::countBuilder($query,$count,$offset); |
|
721 | + self::countBuilder($query, $count, $offset); |
|
722 | 722 | return self::query($query, $var); |
723 | 723 | } |
724 | 724 | |
@@ -736,7 +736,7 @@ discard block |
||
736 | 736 | * |
737 | 737 | * @return null|bool|array |
738 | 738 | */ |
739 | - public static function selectArray (string $table, array|string $columns = '*', array $where = [], array|string $group_by = [], array|string $order_by = [], bool $ignore_default_where = false): bool|array|null { |
|
739 | + public static function selectArray(string $table, array | string $columns = '*', array $where = [], array | string $group_by = [], array | string $order_by = [], bool $ignore_default_where = false): bool | array | null { |
|
740 | 740 | $res = self::select($table, $columns, $where, 1, 0, $group_by, $order_by, ignore_default_where: $ignore_default_where); |
741 | 741 | if ($res) { |
742 | 742 | return $res->fetch_assoc(); |
@@ -758,7 +758,7 @@ discard block |
||
758 | 758 | * |
759 | 759 | * @return null|object |
760 | 760 | */ |
761 | - public static function selectObject (string $table, array|string $columns = '*', array $where = [], array|string $group_by = [], array|string $order_by = [], bool $ignore_default_where = false) { |
|
761 | + public static function selectObject(string $table, array | string $columns = '*', array $where = [], array | string $group_by = [], array | string $order_by = [], bool $ignore_default_where = false) { |
|
762 | 762 | $res = self::select($table, $columns, $where, 1, 0, $group_by, $order_by, ignore_default_where: $ignore_default_where); |
763 | 763 | if ($res) { |
764 | 764 | return $res->fetch_object(); |
@@ -783,7 +783,7 @@ discard block |
||
783 | 783 | * |
784 | 784 | * @return bool|Generator |
785 | 785 | */ |
786 | - public static function selectEach (string $table, array|string $columns = '*', array $where = [], int $count = null, int $offset = null, array|string $group_by = [], array|string $order_by = [], bool $ignore_default_where = false): bool|Generator { |
|
786 | + public static function selectEach(string $table, array | string $columns = '*', array $where = [], int $count = null, int $offset = null, array | string $group_by = [], array | string $order_by = [], bool $ignore_default_where = false): bool | Generator { |
|
787 | 787 | $res = self::select($table, $columns, $where, $count, $offset, $group_by, $order_by, ignore_default_where: $ignore_default_where); |
788 | 788 | if ($res) { |
789 | 789 | while ($row = $res->fetch_assoc()) yield $row; |
@@ -801,10 +801,10 @@ discard block |
||
801 | 801 | * |
802 | 802 | * @return string if save is true , return file name otherwise return sql data |
803 | 803 | */ |
804 | - public static function backup (array $wanted_tables = [], bool $table_data = true, bool $save = true, string $file_name = ''): string { |
|
804 | + public static function backup(array $wanted_tables = [], bool $table_data = true, bool $save = true, string $file_name = ''): string { |
|
805 | 805 | self::setCharset('utf8mb4'); |
806 | 806 | |
807 | - $tables = array_column(self::query('SHOW TABLES')->fetch_all(),0); |
|
807 | + $tables = array_column(self::query('SHOW TABLES')->fetch_all(), 0); |
|
808 | 808 | if (!empty($wanted_tables)) { |
809 | 809 | $tables = array_intersect($tables, $wanted_tables); |
810 | 810 | } |
@@ -815,12 +815,12 @@ discard block |
||
815 | 815 | logger::write('No table founded for backup, if your database has table : check $wanted_tables argument', loggerTypes::WARNING); |
816 | 816 | } |
817 | 817 | foreach ($tables as $table) { |
818 | - $sql .= self::query("SHOW CREATE TABLE `$table`")->fetch_row()[1] . ";\n\n"; |
|
818 | + $sql .= self::query("SHOW CREATE TABLE `$table`")->fetch_row()[1].";\n\n"; |
|
819 | 819 | if ($table_data) { |
820 | 820 | $total_rows = self::query("SELECT COUNT(*) as `cnt` FROM `$table`")->fetch_object()->cnt; |
821 | 821 | for ($i = 0; $i < $total_rows; $i = $i + 1000) { |
822 | - $sql .= 'INSERT INTO ' . $table . ' VALUES'; |
|
823 | - $result = self::select($table, '*' , [], 1000, $i); |
|
822 | + $sql .= 'INSERT INTO '.$table.' VALUES'; |
|
823 | + $result = self::select($table, '*', [], 1000, $i); |
|
824 | 824 | $field_count = $result->field_count; |
825 | 825 | $affected_rows = self::affected_rows(); |
826 | 826 | $counter = 1; |
@@ -828,12 +828,12 @@ discard block |
||
828 | 828 | $sql .= "\n("; |
829 | 829 | for ($column = 0; $column < $field_count; $column++) { |
830 | 830 | $row[$column] = str_replace("\n", "\\n", addslashes($row[$column])); |
831 | - $sql .= !empty($row[$column]) ? '"' . $row[$column] . '"' : '""'; |
|
831 | + $sql .= !empty($row[$column]) ? '"'.$row[$column].'"' : '""'; |
|
832 | 832 | if ($column < $field_count - 1) { |
833 | 833 | $sql .= ','; |
834 | 834 | } |
835 | 835 | } |
836 | - $sql .= ')' . ($counter == $affected_rows ? ';' : ','); |
|
836 | + $sql .= ')'.($counter == $affected_rows ? ';' : ','); |
|
837 | 837 | $counter++; |
838 | 838 | } |
839 | 839 | } |
@@ -849,7 +849,7 @@ discard block |
||
849 | 849 | } |
850 | 850 | |
851 | 851 | if (empty($file_name)) { |
852 | - $file_name = self::$db_name . time() . '.sql'; |
|
852 | + $file_name = self::$db_name.time().'.sql'; |
|
853 | 853 | } |
854 | 854 | file_put_contents($file_name, $sql); |
855 | 855 | return $file_name; |