MyBB Community Forums

Full Version: how can i run a simple sql query with task system
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
i checked task files from inc/tasks dir. but i could understand how they works so can someone gave me a tut for making a simple task file? i think a simple replace query is enough for an example.
If you want to create a new task you have to place a new PHP file in /inc/tasks

It very simple. There are some small "learning tasks" like hourlycleanup.php or threadviews.php
function task_replacetask($task)
{
	global $mybb, $db, $lang;
	
	$replace = array();

	// Update thread views
	
	$query = $db->query("UPDATE ".TABLE_PREFIX."posts SET message= replace(message,'before', 'after')");
	
	add_task_log($task, $lang->task_replacetask_ran);
}
so is this right for a replacetask.php file?
You may need to require_once() for the MYBB_ROOT/global.php file... I'm not sure since I've never messed with tasks to date.
(2009-12-10, 12:39 PM)dared Wrote: [ -> ]
function task_replacetask($task)
{
	global $mybb, $db, $lang;
	
	$replace = array();

	// Update thread views
	
	$query = $db->query("UPDATE ".TABLE_PREFIX."posts SET message= replace(message,'before', 'after')");
	
	add_task_log($task, $lang->task_replacetask_ran);
}
so is this right for a replacetask.php file?

this code is right and works. just create a file named replacetask.php and send it to inc/task dir.

also no need to require_once() for the MYBB_ROOT/global.php