static function db_prefix($table_name = false) { global $wpdb; self::$db_prefix = $wpdb->prefix . self::$name . '_'; if ($table_name) { $prefixed = self::$db_prefix . $table_name; } else { $prefixed = self::$db_prefix; } return $prefixed; }
function __construct() { $this->user_table = WJ_Settings::db_prefix('user'); $this->field_table = WJ_Settings::db_prefix('custom_field'); }
function __construct($new_version) { // Global Wordpress db object. $this->db_prefix = WJ_Settings::db_prefix(); $this->new_version = $new_version; }
public static function get_all($options = array()) { global $wpdb; // default order by $order_by = 'id ASC'; if (isset($options['order_by'])) { $order_by = $options['order_by']; } // fetch rows from db $results = $wpdb->get_results($wpdb->prepare('SELECT * from ' . WJ_Settings::db_prefix(self::$_table) . ' ORDER BY %s', $order_by), ARRAY_A); if (!is_null($results)) { $collection = array(); foreach ($results as $result) { $collection[] = new self($result); } return $collection; } else { return null; } }