Log in

View Full Version : API Question


tdeutsch74
02-12-2009, 10:54 PM
Hey all. I'm creating a few custom PHP pages using vBulletin and it's API that create new threads, replies and users. Once I create a new item, I will need to output the newly created id. I see for the User object that the save method returns the new user id, but there is nothing for threads and posts. For these I'm using vB_DataManager_Thread_FirstPost and vB_DataManager_Post.

Does anyone know how I can retrieve the newly created thread id and post id's when I save them using the API?

Thank you.

Dismounted
02-13-2009, 08:33 AM
The save() method, when used in inserting a new record, will (nearly) always return the ID of the newly inserted row. The only exception is tables that do not have auto increment values (e.g. customavatar).

tdeutsch74
02-13-2009, 04:54 PM
Great that does work. Thanks. I have another quick question. I'm using

vB_DataManager_Thread_FirstPost to create my thread and first post which works, but it is not incrementing the user's post count. I do run build_forum_counters($forum_id); after the save.

Any idea how to get that working?

Thanks.

Dismounted
02-14-2009, 11:34 AM
Does the forum have post counts enabled?

tdeutsch74
02-19-2009, 04:01 PM
Hi. Yes...post counts are enabled in the forum

DragonBlade
02-19-2009, 04:05 PM
The save() method, when used in inserting a new record, will (nearly) always return the ID of the newly inserted row. The only exception is tables that do not have auto increment values (e.g. customavatar).

XD Thanks for this--in a few of mine, I've been using $vbulletin->db->insert_id() instead, not realizing that the datamanagers return the insert ID already. XP

Dismounted
02-20-2009, 04:11 AM
Hi. Yes...post counts are enabled in the forum
Actually, you should consider using the build_new_post() function, as it will send out subscriptions, notifications, etc as well.