我正在尝试使用安全外壳运行存储在wordpress插件PHP Snippet中的SQL更新命令脚本,以对其进行测试,目的是使用tsohost从cron作业中调用同一命令。
下面的PHP代码段
global $wpdb;
global $current_user;
get_currentuserinfo();
$user_id = $current_user->ID;
$result = $wpdb->get_results("
INSERT INTO dm_cash_accounts_transactions (name, amount, type, cash_account_id, user_id)
SELECT
name,
quantity * amount,
type_id,
account_id,
user_id
FROM
dm_scheduledd
WHERE
paydate = DATE(NOW())
AND
dm_scheduledd.user_id = '".$user_id."'
AND
updated = 'n'
");
print_r($result);
我可以使用简码在网页上运行上述代码段
[wbcr_php_snippet id="14984" title="Update Cash Accounts Transactions"]
我正在努力使用安全外壳程序运行上述脚本。我尝试了多种选择
bash-3.2$ wget -O /dev/null --no-check-certificate https://dividendmanager.co.uk/update-cash-accounts-transactions
上面的命令似乎可以正常运行,但是不会更新数据库表。我想我需要一个命令来登录数据库并调用PHP代码段,任何建议都值得赞赏。谢谢科林
最佳答案
如果这是一个独立的php文件,则应加载wp全局引导类,请在文件开头包含wp-load.php;
我不认为bcc也可以检索$current_user
,这与用户会话有关