View Full Version : Help update using datamanager
Easy5s.net
06-19-2015, 11:29 AM
pls help me Update custom field in Thread using datamanager. I have user code
$threadman =& datamanager_init('Thread', $vbulletin, ERRTYPE_STANDARD, 'threadpost');
$threadman->set_existing($threadinfo);
$threadman->set('custom field', $custom field);
$threadman->save();
and hook threaddata_start but not work :(
I'm not sure what you're trying to do, but if you put that code at hook threaddata_start then you're creating a Thread datamanager in the Thread datamanager constructor, which isn't good.
What are you doing, adding a field to the thread creation page, then trying to get the value to the database when the thread is created?
Easy5s.net
06-19-2015, 11:28 PM
I'm not sure what you're trying to do, but if you put that code at hook threaddata_start then you're creating a Thread datamanager in the Thread datamanager constructor, which isn't good.
What are you doing, adding a field to the thread creation page, then trying to get the value to the database when the thread is created?
Sory, I confused, i have hook code to hook misc_start
$threadman =& datamanager_init('Thread', $vbulletin, ERRTYPE_STANDARD, 'threadpost');
$threadman->set_existing($threadinfo);
$threadman->set('custom_field', $custom_field);
$threadman->save();
and hook threaddata_start with code:
$this->validfields['custom_field'] = array(TYPE_INI, REQ_NO);
Now, i have create temp with link to update custom field. No error when click link but database not update. ???
P/S: I do not want use UPDATE " . TABLE_PREFIX . "thread
.....
MarkFL
06-20-2015, 12:10 AM
Try replacing all instances of "custom field" with "custom_field"...you cannot have spaces embedded in variable names. :D
Easy5s.net
06-20-2015, 12:31 AM
Try replacing all instances of "custom field" with "custom_field"...you cannot have spaces embedded in variable names. :D
:D, That is just an example.
Hmm...ok. Well, there is no TYPE_INI, maybe you mean TYPE_INT. But I don't know if that would stop it from working. Are you sure $threadinfo is set? You might have to set that yourself. Or it might be enough to just do something like
$threadman->set_existing(array('threadid' => $threadid));
if you just have the threadid.
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.