1: <?php
2:
3: namespace ModHelper;
4:
5: /**
6: * This file deals with some database internals.
7: *
8: * @package ModHelper
9: * @since 1.0
10: */
11: class Database
12: {
13: /**
14: * Handler to SMF's database functions.
15: *
16: * @example ModHelper\Database::query('', 'SELECT * FROM smf_themes', array());
17: * @param string $name The name (or key) of the $smcFunc you are calling.
18: * @param string $arguments This is an array of all arguments passed to the method.
19: * @return mixed The $smcFunc return value or false if not found.
20: * @throws BadFunctionCallException
21: * @since 1.0
22: * @version 1.1
23: */
24: public static function __callStatic($name, $arguments)
25: {
26: global $smcFunc;
27: if (isset($smcFunc[$name = 'db_' . $name])) {
28: if (!is_callable($smcFunc[$name])) {
29: throw new \BadFunctionCallException('Function $smcFunc[' . $name . '] is not callable');
30: }
31: return call_user_func_array($smcFunc[$name], $arguments);
32: }
33:
34: return false;
35: }
36: }
37: