You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Tried to delete table, but when the system recreates it, fatal error occurs
*** Previously... *
Hi Ludicrous Community!
I need some help.
I'm trying to configure LudicrousDB so that tables created with NS Cloner (now WP Clone) for the subsites I'm interested in end up in another database.
Let me explain further:
I have a subsite that I clone each time so that everything I need is already set up. Since I have many subsites and each one has a specific number in the table prefix, I want to move certain subsites to another database (for example, those containing numbers from 51 to 100 in the database prefix).
The cloning process creates them in the first database. The simplest thing for me is to export those tables, once created, to the new database and make sure LudicrousDB understands where they ended up.
I've set everything up as per the guide, but I find that LudicrousDB always reads from the first database.
If I delete the tables from the first database, it returns 'not found', so there's definitely something that I'm missing in all of this.
Do you have any advice on how to proceed?
I modified the db-config.php file as follows:
/**
* This is the most basic way to add a server to LudicrousDB using only the
* required parameters: host, user, password, name.
* This adds the DB defined in wp-config.php as a read/write server for
* the 'global' dataset. (Every table is in 'global' by default.)
*/
$wpdb->add_database( array(
'host' => DB_HOST, // If port is other than 3306, use host:port.
'user' => DB_USER,
'password' => DB_PASSWORD,
'name' => DB_NAME,
'dataset' => 'global',
) );
/**
* This adds the same server again, only this time it is configured as a slave.
* The last three parameters are set to the defaults but are shown for clarity.
*/
$wpdb->add_database( array(
'host' => 'localhost', // If port is other than 3306, use host:port.
'user' => 'user01',
'password' => 'pwd01',
'name' => 'db02',
'dataset' => 'sites_from_51_to_100'
) );
$wpdb->add_database( array(
'host' => 'localhost', // If port is other than 3306, use host:port.
'user' => 'user01',
'password' => 'pwd01',
'name' => 'db03,
'dataset' => 'sites_from_101_to_150'
) );
$wpdb->add_callback('resolve_with_dataset');
function resolve_with_dataset($query, $wpdb) {
if ( preg_match("/^{$wpdb->base_prefix}(5[1-9]|[6-9][0-9]|100)_/i", $wpdb->table) ) {
// code to execute if the pattern matches
return 'sites_from_51_to_100';
} elseif ( preg_match("/^{$wpdb->base_prefix}(10[1-9]|11[0-9]|120|130|140|150)_/i", $wpdb->table) ) {
// code to execute if the pattern matches numbers between 101 and 150
return 'sites_from_101_to_150';
} else {
return null; // Default to global dataset if no match
}
}
Thank you in advance for your valuable assistance.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
*** EDITED ***
LUDICROUS DB is working but system finds incompatibility with Elementor Pro
Tried to delete table, but when the system recreates it, fatal error occurs
*** Previously... *
Hi Ludicrous Community!
I need some help.
I'm trying to configure LudicrousDB so that tables created with NS Cloner (now WP Clone) for the subsites I'm interested in end up in another database.
Let me explain further:
I have a subsite that I clone each time so that everything I need is already set up. Since I have many subsites and each one has a specific number in the table prefix, I want to move certain subsites to another database (for example, those containing numbers from 51 to 100 in the database prefix).
The cloning process creates them in the first database. The simplest thing for me is to export those tables, once created, to the new database and make sure LudicrousDB understands where they ended up.
I've set everything up as per the guide, but I find that LudicrousDB always reads from the first database.
If I delete the tables from the first database, it returns 'not found', so there's definitely something that I'm missing in all of this.
Do you have any advice on how to proceed?
I modified the db-config.php file as follows:
Thank you in advance for your valuable assistance.
Beta Was this translation helpful? Give feedback.
All reactions