admin管理员组文章数量:1022769
I run into a problem I can't seem to fix. I went back and forth and even used $wpdb->prepare()
and $wpdb->query()
functions, nothing helps.
$table_prefix."users"
returns wp_2qttgdv7ac_2_users
(slightly changed in post for security purposes). Yes, I've tried $wpdb->prefix
as well. Same result.
$wpdb->update($table_prefix."users", array('user_email' => $fetch_data['new_email']), array('user_login' => $fetch_data['username']))
This was not working, but on running...
var_dump( $wpdb->last_error)
I get the error:
string(59) "Table 'A41K421094D3615.wp_2qttgdv7ac_2_users' doesn't exist"
Here A41K421094D3615 is the database name. I am running in a multi-site environment. However, accessing custom tables does not add database name in front of the table. How can I get it to stop adding it? Or at least make it honor the table. Usually database_name.table_name should work, right? However, it's returning that it does not exist. Any suggestions?
I run into a problem I can't seem to fix. I went back and forth and even used $wpdb->prepare()
and $wpdb->query()
functions, nothing helps.
$table_prefix."users"
returns wp_2qttgdv7ac_2_users
(slightly changed in post for security purposes). Yes, I've tried $wpdb->prefix
as well. Same result.
$wpdb->update($table_prefix."users", array('user_email' => $fetch_data['new_email']), array('user_login' => $fetch_data['username']))
This was not working, but on running...
var_dump( $wpdb->last_error)
I get the error:
string(59) "Table 'A41K421094D3615.wp_2qttgdv7ac_2_users' doesn't exist"
Here A41K421094D3615 is the database name. I am running in a multi-site environment. However, accessing custom tables does not add database name in front of the table. How can I get it to stop adding it? Or at least make it honor the table. Usually database_name.table_name should work, right? However, it's returning that it does not exist. Any suggestions?
Share Improve this question edited May 18, 2019 at 15:22 fuxia♦ 107k39 gold badges255 silver badges459 bronze badges asked May 16, 2019 at 4:17 Mafuyu-ChamaMafuyu-Chama 12 bronze badges 2 |1 Answer
Reset to default 1Use $wpdb->base_prefix for 'users' table.
I run into a problem I can't seem to fix. I went back and forth and even used $wpdb->prepare()
and $wpdb->query()
functions, nothing helps.
$table_prefix."users"
returns wp_2qttgdv7ac_2_users
(slightly changed in post for security purposes). Yes, I've tried $wpdb->prefix
as well. Same result.
$wpdb->update($table_prefix."users", array('user_email' => $fetch_data['new_email']), array('user_login' => $fetch_data['username']))
This was not working, but on running...
var_dump( $wpdb->last_error)
I get the error:
string(59) "Table 'A41K421094D3615.wp_2qttgdv7ac_2_users' doesn't exist"
Here A41K421094D3615 is the database name. I am running in a multi-site environment. However, accessing custom tables does not add database name in front of the table. How can I get it to stop adding it? Or at least make it honor the table. Usually database_name.table_name should work, right? However, it's returning that it does not exist. Any suggestions?
I run into a problem I can't seem to fix. I went back and forth and even used $wpdb->prepare()
and $wpdb->query()
functions, nothing helps.
$table_prefix."users"
returns wp_2qttgdv7ac_2_users
(slightly changed in post for security purposes). Yes, I've tried $wpdb->prefix
as well. Same result.
$wpdb->update($table_prefix."users", array('user_email' => $fetch_data['new_email']), array('user_login' => $fetch_data['username']))
This was not working, but on running...
var_dump( $wpdb->last_error)
I get the error:
string(59) "Table 'A41K421094D3615.wp_2qttgdv7ac_2_users' doesn't exist"
Here A41K421094D3615 is the database name. I am running in a multi-site environment. However, accessing custom tables does not add database name in front of the table. How can I get it to stop adding it? Or at least make it honor the table. Usually database_name.table_name should work, right? However, it's returning that it does not exist. Any suggestions?
Share Improve this question edited May 18, 2019 at 15:22 fuxia♦ 107k39 gold badges255 silver badges459 bronze badges asked May 16, 2019 at 4:17 Mafuyu-ChamaMafuyu-Chama 12 bronze badges 2-
WordPress isn't adding the table name to the SQL: MySQL is including it for context when it's generating the error. Try
use A41K421094D3615; select * from wp_2qttgdv7ac_2_users;
in MySQL and you'll get the same error even though the database name wasn't in the SELECT. Does that table actually exist? – Rup Commented May 16, 2019 at 16:30 - You are right wp_2qttgdv7ac_2_users doesn't exist when I confirmed with PhpMyAdmin. Users for multisite is saved on the same table wp_2qttgdv7ac_users as other sites on a multisite network. Using $wpdb->prefix and $table_prefix provides "wp_2qttgdv7ac_2_" - using $wpdb->base_prefix solved the problem. – Mafuyu-Chama Commented May 16, 2019 at 16:58
1 Answer
Reset to default 1Use $wpdb->base_prefix for 'users' table.
本文标签: multisitewpdbgtupdate prefixes database name to table when executing query
版权声明:本文标题:multisite - $wpdb->update prefixes database name to table when executing query 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745482218a2152585.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
use A41K421094D3615; select * from wp_2qttgdv7ac_2_users;
in MySQL and you'll get the same error even though the database name wasn't in the SELECT. Does that table actually exist? – Rup Commented May 16, 2019 at 16:30