class-clauses.php
2 years ago
class-database.php
2 years ago
class-escape.php
2 years ago
class-groupby.php
2 years ago
class-joins.php
2 years ago
class-orderby.php
2 years ago
class-query-builder.php
2 years ago
class-select.php
2 years ago
class-translate.php
2 years ago
class-where.php
2 years ago
index.php
2 years ago
class-database.php
42 lines
| 1 | <?php |
| 2 | /** |
| 3 | * The Database. |
| 4 | * |
| 5 | * @since 1.0.0 |
| 6 | * @package MyThemeShop |
| 7 | * @subpackage MyThemeShop\Database |
| 8 | * @author MyThemeShop <admin@mythemeshop.com> |
| 9 | */ |
| 10 | |
| 11 | namespace MyThemeShop\Database; |
| 12 | |
| 13 | /** |
| 14 | * Database class. |
| 15 | */ |
| 16 | class Database { |
| 17 | |
| 18 | /** |
| 19 | * Array of all databases objects. |
| 20 | * |
| 21 | * @var array |
| 22 | */ |
| 23 | protected static $instances = array(); |
| 24 | |
| 25 | /** |
| 26 | * Retrieve a Database instance by table name. |
| 27 | * |
| 28 | * @param string $table_name A Database instance id. |
| 29 | * |
| 30 | * @return Database Database object instance. |
| 31 | */ |
| 32 | public static function table( $table_name ) { |
| 33 | global $wpdb; |
| 34 | |
| 35 | if ( empty( self::$instances ) || empty( self::$instances[ $table_name ] ) ) { |
| 36 | self::$instances[ $table_name ] = new Query_Builder( $wpdb->prefix . $table_name ); |
| 37 | } |
| 38 | |
| 39 | return self::$instances[ $table_name ]; |
| 40 | } |
| 41 | } |
| 42 |