Go Back   vb.org Archive > vBulletin Article Depository > Read An Article > vBulletin 3 Articles
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
Create Posts
fly
Join Date: Oct 2003
Posts: 1,215

 

Show Printable Version Email this Page Subscription
fly fly is offline 12-06-2005, 10:00 PM

PHP Code:
require_once('./global.php');
require_once(
'./includes/class_dm.php');
require_once(
'./includes/class_dm_threadpost.php');

$postdm = new vB_DataManager_Post($vbulletinERRTYPE_STANDARD);

$postthreadid '4473';
$postusername 'admin';
// Use $postusername if posting as a guest, use $postuserid if posting as a user
//$postuserid = '1';
$postpagetext 'Hi mom!';

$threadinfo fetch_threadinfo($postthreadid);
$foruminfo fetch_foruminfo($threadinfo['forumid']);

$postdm->set_info('forum'$foruminfo);
$postdm->set_info('thread'$threadinfo);  
$postdm->set('threadid'$postthreadid);
$postdm->set('username'$postusername);
// Use $postusername if posting as a guest, use $postuserid if posting as a user
//$postdm->set('userid', $postuserid);
$postdm->set('pagetext'$postpagetext);
$postdm->set('allowsmilie'1);
$postdm->set('visible'1);
$postdm->set('dateline'TIMENOW);
$postdm->save();
unset(
$postdm); 
Reply With Quote
  #62  
Old 07-22-2008, 06:53 PM
fly fly is offline
 
Join Date: Oct 2003
Posts: 1,215
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by dlitec View Post
hmm sorry its me again

i wonder if its possible to vote threads with this too?!

i tried this:
PHP Code:
$postdm->set('votetotal'$voted); 
but recieved the standard error:
Field votetotal is not defined in $validfields in class vB_DataManager_Post in [path]/includes/class_dm.php

anyone has a clue?

edit:
extending in class_dm.php with this variable works.. no error anymore, but the voting is not transfered. do i really have to write into the DB directly? or is there a way?
This is really offtopic for this thread, but if you want to rate threads, I'd check out class_dm_threadrate.php. If you want to vote in polls, class_dm_pollvote.php probably has what you need.

edit:
http://members.vbulletin.com/api/vBu...drate.php.html
http://members.vbulletin.com/api/vBu...lvote.php.html
Reply With Quote
  #63  
Old 07-23-2008, 06:34 AM
dlitec dlitec is offline
 
Join Date: Jul 2008
Posts: 4
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

thanks for your advice.. i now solved it with direct db-query's ... i dont like the datamanager

i think next time i'll stay straight with php and mysql.
Reply With Quote
  #64  
Old 07-24-2008, 06:44 AM
Hereward Hereward is offline
 
Join Date: Jun 2008
Posts: 9
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hi there,

I am trying to work out how to perform an update as opposed to an insert on the text of the first post of a thread.

I currently have the following which works fine for inserts:

PHP Code:
$threaddm =& datamanager_init('Thread_FirstPost'$vbulletinERRTYPE_ARRAY'threadpost');
$forumid 36//$vbulletin->GPC['fid']; // can also be a number ;) $forumdid= 12;
$foruminfo fetch_foruminfo($forumid);
$threaddm->set_info('forum'$foruminfo);
$threaddm->set('forumid'$foruminfo['forumid']);
$threaddm->set('userid'1);
$threaddm->set('title'$title);
$threaddm->set('pagetext'$body);
$threaddm->set('allowsmilie'1);
$threaddm->set('visible'1);
$threaddm->set('dateline'TIMENOW);
$threadid $threaddm->save(); 
Is there a way to change this from an insert to an update, by passsing in the threadid for example?

I tried this, which generated a 503 error:
PHP Code:
$threaddm->set('threadid'$threadid); 
Reply With Quote
  #65  
Old 07-26-2008, 12:20 PM
Hereward Hereward is offline
 
Join Date: Jun 2008
Posts: 9
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I have spent many hours now trying to solve the humble little problem stated above with no success.

this is heartbreaking.

I tried to set the post id using this:
PHP Code:
    $postid $postdm->fetch_field('firstpostid');
    
$postdm->set('postid'$postid); 
didn't work
Reply With Quote
  #66  
Old 07-26-2008, 01:48 PM
fly fly is offline
 
Join Date: Oct 2003
Posts: 1,215
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Hereward View Post
I have spent many hours now trying to solve the humble little problem stated above with no success.

this is heartbreaking.

I tried to set the post id using this:
PHP Code:
    $postid $postdm->fetch_field('firstpostid');
    
$postdm->set('postid'$postid); 
didn't work
Do it with a SQL query then...
Reply With Quote
  #67  
Old 07-27-2008, 03:01 AM
Hereward Hereward is offline
 
Join Date: Jun 2008
Posts: 9
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

yeah that's exactly what I am going to do, but it seems wrong when there is an API which supposedly can do all this - but since I do not understand how it works and cannot find a working example or documentation other than the comments in the code itself it doesn;t seem likely that I am going to work it out without a miracle.
Reply With Quote
  #68  
Old 07-27-2008, 05:52 AM
amcd amcd is offline
 
Join Date: Oct 2004
Posts: 218
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

There is no miracle needed. The vbulletin code is very well organized and commented.

I guess there must be a way of telling the thread data manager to pre-load itself with the thread. Then change whatever you want to and tell it to save. That should do an update.

Read the data manager class in the includes directory. Or else read any of the default vb scripts which o an update, such as the edit thread function from thread tools dropdown.
Reply With Quote
  #69  
Old 07-27-2008, 12:38 PM
Hereward Hereward is offline
 
Join Date: Jun 2008
Posts: 9
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

"well documented" ..? you gotta be joking

but I have figured it out now:
In order to force the save command to do an update instead of an insert you need to use
set_existing:

PHP Code:
$existing = array('userid' => $userid,'threadid'=>$threadid);
$threaddm->set_existing($existing); 
This works (: (:
Reply With Quote
  #70  
Old 07-27-2008, 12:54 PM
amcd amcd is offline
 
Join Date: Oct 2004
Posts: 218
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Hereward View Post
"well documented" ..? you gotta be joking
It is. You haven't seen the bad stuff. There are a huge number of scripts out there which are not even indented properly and are being sold for $400 and above.
Reply With Quote
  #71  
Old 07-30-2008, 04:08 AM
nuk3 nuk3 is offline
 
Join Date: Jan 2005
Posts: 3
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Hereward View Post
"well documented" ..? you gotta be joking
Quote:
Setting the existing data (if necessary)
If you are using the data managers to insert a new record into the database, you do not need to perform this step. However, if you are updating an existing record (eg, editing a post), this step is mandatory.

To set the existing data, you must call the set_existing method of the data manager object.

set_existing(&$existing)

The $existing is an array of data that is currently stored in the database. It should include all the fields this data manager handles as keys. *snip*
http://www.vbulletin.com/docs/html/d...er_programming

How you could've not checked and/or found that documentation in the first place is seriously beyond me, being the first result on google for vbulletin datamanager and all. It explains everything you could need to know and also has relevant real world examples provided too. So take your ignorant minded "well documented" attack and shove it.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 06:55 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.05113 seconds
  • Memory Usage 2,351KB
  • Queries Executed 26 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (7)bbcode_php
  • (5)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_article
  • (1)navbar
  • (4)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)pagenav_pagelink
  • (11)post_thanks_box
  • (1)post_thanks_box_bit
  • (11)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit
  • (11)post_thanks_postbit_info
  • (10)postbit
  • (11)postbit_onlinestatus
  • (11)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • fetch_musername
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • post_thanks_function_fetch_thanks_bit_start
  • post_thanks_function_show_thanks_date_start
  • post_thanks_function_show_thanks_date_end
  • post_thanks_function_fetch_thanks_bit_end
  • post_thanks_function_fetch_post_thanks_template_start
  • post_thanks_function_fetch_post_thanks_template_end
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete