: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
if (!defined('ABSPATH')) exit;
if (!class_exists('BVWPDb')) :
public function dbprefix() {
$prefix = $wpdb->base_prefix ? $wpdb->base_prefix : $wpdb->prefix;
public function prepare($query, $args) {
return $wpdb->prepare($query, $args);
public function getSiteId() {
public function getResult($query, $obj = ARRAY_A) {
return $wpdb->get_results($query, $obj);
public function query($query) {
return $wpdb->query($query);
public function getVar($query, $col = 0, $row = 0) {
return $wpdb->get_var($query, $col, $row);
public function getCol($query, $col = 0) {
return $wpdb->get_col($query, $col);
public function tableName($table) {
public function showTables() {
$tables = $this->getResult("SHOW TABLES", ARRAY_N);
return array_map(array($this, 'tableName'), $tables);
public function showTableStatus() {
return $this->getResult("SHOW TABLE STATUS");
public function tableKeys($table) {
return $this->getResult("SHOW KEYS FROM $table;");
public function showDbVariables($variable) {
$variables = $this->getResult("Show variables like '%$variable%' ;");
foreach ($variables as $variable) {
$result[$variable["Variable_name"]] = $variable["Value"];
public function describeTable($table) {
return $this->getResult("DESCRIBE $table;");
public function showTableIndex($table) {
return $this->getResult("SHOW INDEX FROM $table");
public function checkTable($table, $type) {
return $this->getResult("CHECK TABLE $table $type;");
public function repairTable($table) {
return $this->getResult("REPAIR TABLE $table;");
public function showTableCreate($table) {
return $this->getVar("SHOW CREATE TABLE $table;", 1);
public function rowsCount($table) {
$count = $this->getVar("SELECT COUNT(*) FROM $table;");
public function createTable($query, $name, $usedbdelta = false) {
$table = $this->getBVTable($name);
if (!$this->isTablePresent($table)) {
if (!function_exists('dbDelta'))
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
return $this->isTablePresent($table);
public function createTables($tables, $usedbdelta = false) {
foreach ($tables as $table => $query) {
$result[$table] = $this->createTable($query, $table, $usedbdelta);
public function alterBVTable($query, $name) {
$table = $this->getBVTable($name);
if ($this->isTablePresent($table)) {
$resp = $this->query($query);
public function alterTables($tables) {
foreach ($tables as $table => $query) {
$result[$table] = $this->alterBVTable($query, $table);
public function getTableContent($table, $fields = '*', $filter = '', $limit = 0, $offset = 0) {
$query = "SELECT $fields from $table $filter";
$query .= " LIMIT $limit";
$query .= " OFFSET $offset";
$rows = $this->getResult($query);
public function isTablePresent($table) {
return ($this->getVar("SHOW TABLES LIKE '$table'") === $table);
public function getCharsetCollate() {
return $wpdb->get_charset_collate();
public function getWPTable($name) {
return ($this->dbprefix() . $name);
public function getBVTable($name) {
return ($this->getWPTable("bv_" . $name));
public function truncateBVTable($name) {
$table = $this->getBVTable($name);
if ($this->isTablePresent($table)) {
return $this->query("TRUNCATE TABLE $table;");
public function deleteBVTableContent($name, $filter = "") {
$table = $this->getBVTable($name);
if ($this->isTablePresent($table)) {
return $this->query("DELETE FROM $table $filter;");
public function dropBVTable($name) {
$table = $this->getBVTable($name);
if ($this->isTablePresent($table)) {
$this->query("DROP TABLE IF EXISTS $table;");
return !$this->isTablePresent($table);
public function dropTables($tables) {
foreach ($tables as $table) {
$result[$table] = $this->dropBVTable($table);
public function truncateTables($tables) {
foreach ($tables as $table) {
$result[$table] = $this->truncateBVTable($table);
public function deleteRowsFromtable($name, $count = 1) {
$table = $this->getBVTable($name);
if ($this->isTablePresent($table)) {
return $this->getResult("DELETE FROM $table LIMIT $count;");
public function replaceIntoBVTable($name, $value) {
$table = $this->getBVTable($name);
return $wpdb->replace($table, $value);
public function insertIntoBVTable($name, $value) {
$table = $this->getBVTable($name);
return $wpdb->insert($table, $value);
public function tinfo($name) {
$table = $this->getBVTable($name);
$result['name'] = $table;
if ($this->isTablePresent($table)) {
$result['exists'] = true;
$result['createquery'] = $this->showTableCreate($table);
public function getMysqlVersion() {
return $this->showDbVariables('version')['version'];