connect_errno ) { die ( "Database connection failed." ); } return $connection; } function db_prepare ( MySQLi $connection, string $query ) { if ( ! ( $statement = $connection -> prepare ( $query ) ) ) { die ( "Prepare failed: (" . $connection->errno . ") " . $connection->error ); } return $statement; } function db_bind ( MySQLi_stmt $statement, array $params ) { if ( ! call_user_func_array ( array ( $statement, "bind_param" ), array_merge ( $params [ 0 ], $params [ 1 ] ) ) ) { die ( "Binding parameters failed: (" . $statement->errno . ") " . $statement->error ); } } function db_execute ( $statement ) { if ( ! $statement->execute ( ) ) { die ( "Execute failed: (" . $statement->errno . ") " . $statement->error ); } } ?>