如何使用 CRON 作业在 Joomla DB 上运行此查询?

我已经创建了这些查询(并在 PhpMyAdmin 中测试了它们),现在需要在我的 Joomla! 上运行它们。数据库使用调用 .php 文件的 CRON 作业。


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 文件?


胡说叔叔
浏览 101回答 1
1回答

桃花长相依

当您通过 cron 作业运行查询时,您应该包括 joomla 文件 framework.php 和 defines.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();
打开App,查看更多内容
随时随地看视频慕课网APP