Simplify defineTables method.

parent 91717c7b
...@@ -87,7 +87,7 @@ class DB ...@@ -87,7 +87,7 @@ class DB
self::$mysql_credentials = $credentials; self::$mysql_credentials = $credentials;
self::$table_prefix = $table_prefix; self::$table_prefix = $table_prefix;
self::defineTable(); self::defineTables();
return self::$pdo; return self::$pdo;
} }
...@@ -115,7 +115,7 @@ class DB ...@@ -115,7 +115,7 @@ class DB
self::$mysql_credentials = null; self::$mysql_credentials = null;
self::$table_prefix = $table_prefix; self::$table_prefix = $table_prefix;
self::defineTable(); self::defineTables();
return self::$pdo; return self::$pdo;
} }
...@@ -123,34 +123,24 @@ class DB ...@@ -123,34 +123,24 @@ class DB
/** /**
* Define all the table with the proper prefix * Define all the table with the proper prefix
*/ */
protected static function defineTable() protected static function defineTables()
{ {
if (!defined('TB_TELEGRAM_UPDATE')) { $tables = [
define('TB_TELEGRAM_UPDATE', self::$table_prefix . 'telegram_update'); 'callback_query',
} 'chat',
if (!defined('TB_MESSAGE')) { 'chosen_inline_result',
define('TB_MESSAGE', self::$table_prefix . 'message'); 'edited_message',
} 'inline_query',
if (!defined('TB_EDITED_MESSAGE')) { 'message',
define('TB_EDITED_MESSAGE', self::$table_prefix . 'edited_message'); 'telegram_update',
} 'user',
if (!defined('TB_INLINE_QUERY')) { 'user_chat',
define('TB_INLINE_QUERY', self::$table_prefix . 'inline_query'); ];
} foreach ($tables as $table) {
if (!defined('TB_CHOSEN_INLINE_RESULT')) { $table_name = 'TB_' . strtoupper($table);
define('TB_CHOSEN_INLINE_RESULT', self::$table_prefix . 'chosen_inline_result'); if (!defined($table_name)) {
} define($table_name, self::$table_prefix . $table);
if (!defined('TB_CALLBACK_QUERY')) { }
define('TB_CALLBACK_QUERY', self::$table_prefix . 'callback_query');
}
if (!defined('TB_USER')) {
define('TB_USER', self::$table_prefix . 'user');
}
if (!defined('TB_CHAT')) {
define('TB_CHAT', self::$table_prefix . 'chat');
}
if (!defined('TB_USER_CHAT')) {
define('TB_USER_CHAT', self::$table_prefix . 'user_chat');
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment