View Full Version : how to use vB_DataManager_Post_Multiple ?
netwind
08-17-2007, 03:55 AM
I't trying delete multiply posts :
$postdm=& datamanager_init('Post', $vbulletin, ERRTYPE_ARRAY, 'threadpost');
$postdm->set_condition("threadid=200 and not parentid = 0");
$count_post+=$postdm->delete();
$postdm->has_errors(true);
unset($postdm);
but nothing happens.
Is this class really functioning ?
Eikinskjaldi
08-17-2007, 05:12 AM
I't trying delete multiply posts :
$postdm=& datamanager_init('Post', $vbulletin, ERRTYPE_ARRAY, 'threadpost');
$postdm->set_condition("threadid=200");
$count_post+=$postdm->delete();
$postdm->has_errors(true);
unset($postdm);
but nothing happens.
Is this class really functioning ?
A few things, firstly, why not just delete the thread? I am not really sure what will happen if you delete all posts from a thread but leave the thread lying around
secondly, assuming you do want an empty thread, you should be using "Post_Multiple", not "Post" the Post dm is pretty much expecting a single postid
Thirdly, pass true into delete
netwind
08-17-2007, 05:40 AM
This is reduced version. there must be "..and not parentid = 0".
a worked example from admincp/forum.php :
$forumdata =& datamanager_init('Forum', $vbulletin, ERRTYPE_CP);
$forumdata->set_condition("FIND_IN_SET(" . $vbulletin->GPC['forumid'] . ", parentlist)");
$forumdata->delete();
define('CP_REDIRECT', 'forum.php');
print_stop_message('deleted_forum_successfully');
this really works and i wrote my code similar
if i make instance of class :
$postdm=& datamanager_init('Post_Multiple', $vbulletin, ERRTYPE_ARRAY, 'threadpost');
i give
Call to undefined function: delete()
Opserty
08-17-2007, 09:16 AM
vB_DataManager_Post_Multiple does not extend vB_DataManager instead it extends the vB_DataMangaer_Multiple class. Within which there is not a delete() function. Hence why you get the error "Call to undefined function".
Eikinskjaldi
08-17-2007, 09:27 AM
Guess you will have to use the Post dm and iterate through it.
You didnt answer the question about just deleting the thread.
netwind
08-17-2007, 09:36 AM
I'm not deleting thread! In first time there was reduced condition for debug purpose.
ok let's condition be
$postdm->set_condition("threadid=200 and not parentid = 0 ");
full condition is more complex.
But this still don't delete any post.
How to iterate? Is it more effective than selecting postid and creating Post_Datamanager in loop ?
I can't undestand how code in admincp/forum.php works without creation of class 'Forum_Multiple'
Opserty
08-17-2007, 12:20 PM
I think there is a delete_post() function somewhere.
Check the Code Documentation for its exact whereabouts and then check the actual PHP to see it can help you.
Eikinskjaldi
08-17-2007, 01:06 PM
How to iterate? Is it more effective than selecting postid and creating Post_Datamanager in loop ?
That's what I meant by iterate :)
Antivirus
08-18-2007, 02:29 AM
I found it easier to loop through repeating calls toa dm than to use the multiple dm calls. Check out the announcement datamanager, there's simple example which helped me get thru it
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.