Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions
  #1  
Old 12-01-2012, 12:25 PM
inmateaid inmateaid is offline
 
Join Date: Nov 2012
Posts: 5
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default datamanager_init('User') save() "Duplicate entry" error in "usertextfield" table

I have spent the last 2 days trying to integrate vB 4.2 into CI 2.1.2...

Everything seems fine, but the datamanager outputs an SQL error page when saving a new user (outside of vB).

My index.php...

PHP Code:
<?php

// vBulletin
define('REGISTERED_USERGROUP'2); // typical default for registered users
define('PERMANENT_COOKIE'false); // false=session cookies (recommended)
define('THIS_SCRIPT'__FILE__); 
define('VB_AREA''External');
$dir getcwd();
chdir('forum/');
require_once(
'./includes/init.php'); // includes class_core.php
require_once('./includes/class_dm.php'); // for class_dm_user.php
require_once('./includes/class_dm_user.php'); // for user functions
require_once('./includes/functions.php'); // vbsetcookie etc.
require_once('./includes/functions_login.php'); // process login/logout 
chdir($dir);

My library...

PHP Code:
<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class 
Forum2 {
    
    private 
$dmuser;
    
    public function 
__construct()
    {
        global 
$vbulletin;
        
$this->dmuser =& datamanager_init('User'$vbulletinERRTYPE_ARRAY);
    }
    
    public function 
register($data = array(), $login FALSE)
    {
        global 
$vbulletin;
        foreach (
$data as $key => $value) {
            if (!
is_array($value)) {
                
$this->dmuser->set($key$value);
            }
        }
        if (isset(
$data['options']) && is_array($data['options'])) {
            foreach (
$data['options'] as $key => $value) {
                
$this->dmuser->set_bitfield('options'$key$value);
            }
        }
        
$this->dmuser->pre_save();
        
//print_r($this->dm);
        
if (count($this->dmuser->errors) > 0) {
            return 
implode('<li>'$this->dmuser->errors);
        }
        return 
$this->dm->save();
    }
}

My controller...

PHP Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class 
Sandbox extends CI_Controller {

    public function 
__construct()
    {
        
parent::__construct();
    }
    
    public function 
vb_test()
    {
        
$this->load->library('forum2');
        
$this->forum2->register(array(
            
'username'    => 'testing5',
            
'email'        => 'test@test5.com',
            
'password'    => 'password5'
        
));
    }

}

Loading mydomain.com/sandbox/vb_test generates the vB sql error page and I receive the following email...

Code:
Database error in vBulletin 4.2.0:

Invalid SQL:
INSERT INTO usertextfield
	(userid)
VALUES
	(29);

MySQL Error   : Duplicate entry '29' for key 1

I am at a loss. Why is the datamanager is trying to insert the "usertextfield" record twice? The records for user, userfield, and usertextfield are all added to the database. I simply can't figure out why the sql error is coming through using the datamanager. I've rewritten this library a few times already to make sure it was an issue with me providing incorrect data to the manager, but nothing gets around this problem.

Please help

Notes: We have a custom cms in place that already has users. Any new registrations will be processed on the main site, and our script adds the forum user to the vB database using the datamanager. Registration and login are handled externally. Login/logout works fine so I did not include those methods in the code above.
Reply With Quote
Reply

Thread Tools
Display Modes

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 02:09 AM.


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.03393 seconds
  • Memory Usage 2,228KB
  • Queries Executed 13 (?)
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
  • (1)bbcode_code
  • (3)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)showthread_list
  • (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_threadedmode.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_threaded
  • showthread_threaded_construct_link
  • 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
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete