i'd use @var store table prefix like:
set @prefix = 'wp_'; to create table names wp_users (wp_ plus users) , wp_usermeta in query below:
set @username = 'username'; set @password = 'p@55w0rd'; set @email = 'em@il.com'; insert `wp_users` (`id`, `user_login`, `user_pass`, `user_nicename`, `user_email`, `user_url`, `user_registered`, `user_activation_key`, `user_status`, `display_name`) values (null , @username, md5(@password), '', @email, '', now(), '', '0', ''); insert `wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`) values (null, last_insert_id(), 'wp_capabilities', 'a:1:{s:13:"administrator";s:1:"1";}'), (null, last_insert_id(), 'wp_user_level', '10'); how can accomplish this? unable find examples used @var part of table name.
*according this can't done:
sql variables can used expressions allowed, not constants or literal identifiers must provided. although it's tempting attempt use variables such things table names, doesn't work.
last modified on saturday, 05 december 2009 14:35
- btw search on "variables can used expressions allowed" turns lot of copies of same content - though seems beyond scope of question identify origin.
fwiw - did test using variable table name:
set @userstable = 'wp_users'; insert `@userstable` [...] insert @userstable [...] and got following errors respectively:
1146 - table '[dbname].@userstable' doesn't exist
1064 - have error in sql syntax; check manual corresponds mysql server version right syntax use near '@userstable
... , complicate things - did find this post relating stored procedures mysql. same syntax fails on insert.
and alas - when adding users wordpress db's via phpmyadmin, have edit table prefixes manually.
Comments
Post a Comment