config = $config; } else { die ( "You can't initialize a database connection without proper configuration." ); } } public function connect ( ) : void { $this->connection = new MySQLi ( $this->config [ 'host' ], $this->config [ 'username' ], $this->config [ 'password' ], $this->config [ 'name' ], $this->config [ 'port' ] ); if ( $this->connection->connect_errno ) { die ( "Database connection failed." ); } } public function prepare ( string $query ) : void { if ( ! ( $this->statement = $this->connection->prepare ( $query ) ) ) { die ( "Prepare failed: (" . $this->connection->errno . ") " . $this->connection->error ); } } public function bind ( array $params ) : void { if ( ! call_user_func_array ( array ( $this->statement, "bind_param" ), array_merge ( $params [ 0 ], $params [ 1 ] ) ) ) { die ( "Binding parameters failed: (" . $this->statement->errno . ") " . $this->statement->error ); } } public function execute ( ) : void { if ( ! $this->statement->execute ( ) ) { die ( "Execute failed: (" . $this->statement->errno . ") " . $this->statement->error ); } } public function get_result ( ) : MySQLi_result { return $this->statement->get_result ( ); } }