vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   [Resolved] DataManager - Add Poll Vote (https://vborg.vbsupport.ru/showthread.php?t=306238)

Captain Tycoon 12-24-2013 01:43 PM

[Resolved] DataManager - Add Poll Vote
 
Hi,

I am trying to use DataManager to vote on a specific poll using the following code.

I am aware that the datamanager pollvote will use 'REPLACE INTO', so even if they already voted, it will still update it with the vote specified.

Code:

                require_once('./global.php');
                require_once('./includes/functions_databuild.php');
                require_once('./includes/class_dm_pollvote.php');
                require_once('./includes/class_dm_poll.php');

                global $vbulletin;
                $pollvote =& datamanager_init('PollVote', $vbulletin, ERRTYPE_STANDARD);
                $pollvote->set('pollid', 125);
                $pollvote->set('votedate', TIMENOW);
                $pollvote->set('voteoption', 1);
                $pollvote->set('userid', 1);
                $pollvote->set('votetype', 0);
                $pollvote->pre_save;
                if(!count($pollvote->errors) < 1)
                {
                        echo "An error occured when voting:". $pollvote->errors[0] . $pollvote->errors[1] . $pollvote->errors[2] ;
                }
                else
                {
                        $pollvoteid = $pollvote->save;
                }

Unfortunately, it does not work - doesn't insert the record into table 'pollvote', and it does not update the record in table 'poll' either. No errors from the if statement either (it runs the else statement).

Edit: Fixed by adding $pollvote->save(); <-- brackets


All times are GMT. The time now is 02:28 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01031 seconds
  • Memory Usage 1,709KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_code_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (1)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete