1010class Database {
1111
1212 /** The database config */
13- protected $ dbconfig ;
13+ protected $ config ;
1414 /** The database connection */
1515 public $ con ;
1616
1717 /**
1818 * Constructor.
19- * @param array $dbconfig - configuration array (see README.md)
19+ * @param array $config - configuration array (see README.md)
2020 * @param \TgUtils\Auth\CredentialsProvider $provider - provider for credentials from an external source (optional)
2121 */
22- public function __construct ($ dbconfig , \TgUtils \Auth \CredentialsProvider $ provider = NULL ) {
23- $ this ->dbconfig = $ dbconfig ;
22+ public function __construct ($ config , \TgUtils \Auth \CredentialsProvider $ provider = NULL ) {
23+ $ this ->config = $ config ;
2424 $ this ->connect ($ provider );
2525 }
2626
@@ -36,15 +36,15 @@ protected function connect(\TgUtils\Auth\CredentialsProvider $provider = NULL) {
3636 $ username = $ provider ->getUsername ();
3737 $ password = $ provider ->getPassword ();
3838 } else {
39- $ username = $ this ->dbconfig ['user ' ];
40- $ password = $ this ->dbconfig ['pass ' ];
39+ $ username = $ this ->config ['user ' ];
40+ $ password = $ this ->config ['pass ' ];
4141 }
4242 $ this ->con = new \mysqli (
43- $ this ->dbconfig ['host ' ],
43+ $ this ->config ['host ' ],
4444 $ username ,
4545 $ password ,
46- $ this ->dbconfig ['dbname ' ],
47- $ this ->dbconfig ['port ' ]
46+ $ this ->config ['dbname ' ],
47+ $ this ->config ['port ' ]
4848 );
4949 if ($ this ->con ->connect_errno ) {
5050 error_log ('Failed to connect to MySQL: ' .$ this ->con ->connect_errno );
@@ -291,8 +291,8 @@ public function updateSingle($table, $fields, $where) {
291291 * @param string $s - the table name
292292 * @param string the table name with prefix replaced
293293 */
294- protected function replaceTablePrefix ($ s ) {
295- $ prefix = $ this ->dbconfig ['tablePrefix ' ];
294+ public function replaceTablePrefix ($ s ) {
295+ $ prefix = $ this ->config ['tablePrefix ' ];
296296 if (!$ prefix ) $ prefix = '' ;
297297 return str_replace ('#__ ' , $ prefix , $ s );
298298 }
0 commit comments