如何使用CRON作业在Joomla DB上运行此查询?
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了如何使用CRON作业在Joomla DB上运行此查询?相关的知识,希望对你有一定的参考价值。
我已经创建了这些查询(并在phpMyAdmin中对其进行了测试),现在需要在我的Joomla上运行它们! DB使用CRON作业调用.php文件。
DELETE FROM j25_virtuemart_vmuser_shoppergroups WHERE id IN(
SELECT * FROM (
SELECT SG.id FROM j25_virtuemart_vmuser_shoppergroups SG
JOIN j25_acym_user AU on AU.cms_id = SG.virtuemart_user_id
JOIN j25_acym_user_has_list AUL ON AUL.user_id = AU.id
where SG.virtuemart_shoppergroup_id = 10 AND (AUL.list_id = 13 AND AUL.status=0)
) as P
);
INSERT INTO j25_virtuemart_vmuser_shoppergroups (virtuemart_user_id, virtuemart_shoppergroup_id)
SELECT * FROM( SELECT cms_id, '10'
FROM j25_acym_user_has_list AUL
left JOIN j25_acym_user AU ON AUL.user_id = AU.id
left JOIN j25_virtuemart_vmuser_shoppergroups SG on AU.cms_id = SG.virtuemart_user_id
where SG.virtuemart_shoppergroup_id IS NULL AND (AUL.list_id = 13 AND AUL.status=1)) as foo
ON duplicate KEY update
virtuemart_shoppergroup_id=virtuemart_shoppergroup_id;
如何将其转换为一个(或2个)可以使用WGET调用的PHP文件?
答案
通过cron作业运行查询时,应包含joomla文件framework.php和define.php,请尝试以下代码
define('_JEXEC', 1);
define('DS', DIRECTORY_SEPARATOR);
define('JPATH_BASE', $_SERVER['DOCUMENT_ROOT'] . DS . '');
require_once (JPATH_BASE . DS . 'includes' . DS . 'defines.php');
require_once (JPATH_BASE . DS . 'includes' . DS . 'framework.php');
$db = JFactory::getDbo();
$query = 'DELETE FROM j25_virtuemart_vmuser_shoppergroups WHERE id IN(
SELECT * FROM (
SELECT SG.id FROM j25_virtuemart_vmuser_shoppergroups SG
JOIN j25_acym_user AU on AU.cms_id = SG.virtuemart_user_id
JOIN j25_acym_user_has_list AUL ON AUL.user_id = AU.id
where SG.virtuemart_shoppergroup_id = 10 AND (AUL.list_id = 13 AND AUL.status=0)
) as P
)';
$db->setQuery($query);
$db->query();
以上是关于如何使用CRON作业在Joomla DB上运行此查询?的主要内容,如果未能解决你的问题,请参考以下文章
在 PHP 脚本上运行 Cron 作业,在 Windows 的本地主机上