View Single Post
  #3  
Old 06-04-2007, 02:57 PM
Antivirus's Avatar
Antivirus Antivirus is offline
 
Join Date: Sep 2004
Location: Black Lagoon
Posts: 1,090
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

ah, i didn't notice those being in bitfields. Thanks for pointing that out.

Is it possible then to use a datamanager to save data into 2 different tables at the same time? Would the primary info be inserted into the table through the class's normal functions of class vB_DataManager, then the repeating data (1 or more details related to the primary data) be inserted by including the actual query info within the class vB_DataManager_Multiple?

Here's the class in progress:
PHP Code:
if (!class_exists('vB_DataManager'))
{
    exit;
}

/**
* Class to do data save/delete operations for FEEDBACK
*
*/
class vB_DataManager_Feedback extends vB_DataManager
{
    
/**
    * Array of recognised and required fields for feedbacks, and their types
    *
    * @var    array
    */
    
var $validfields = array(
        
// following data is for table scst_fb
        
'fbid'            => array(TYPE_UINT,        REQ_INCR'verify_nonzero'),
        
'title'            => array(TYPE_STR,        REQ_YES'return ($data != \'\');'),
        
'userid'        => array(TYPE_UINT,        REQ_YESVF_METHOD),
        
'taskid'        => array(TYPE_UINT,        REQ_YESVF_METHOD),
        
'eventid'        => array(TYPE_UINT,        REQ_YESVF_METHOD),
        
// following data is for scst_fbposts (1 or more records linked to above by way of field fbid)
        
'fbid'            => array(TYPE_UINT,        REQ_YES), // same fbid as above for each record
        
'userid'        => array(TYPE_UINT,        REQ_YESVF_METHOD), // same userid as above for each record
        
'fbscore'        => array(TYPE_UINT,        REQ_NO),
        
'postid'        => array(TYPE_UINT,        REQ_INCR'verify_nonzero'),
        
'statusid'        => array(TYPE_UINT,        REQ_NO),
        
'teamid'        => array(TYPE_UINT,        REQ_NO),
        
'dateline'        => array(TYPE_UNIXTIMEREQ_YES),
        
'infraction'    => array(TYPE_UINT,        REQ_NO),
        
'allowsmile'    => array(TYPE_BOOL,        REQ_NO),
        
'showsignature'    => array(TYPE_BOOL,        REQ_NO),
        
'hide'            => array(TYPE_BOOL,        REQ_NO),
        
'score'            => array(TYPE_UINT,        REQ_NO),
        
'attach'        => array(TYPE_UINT,        REQ_NO),
        
'pagetext'        => array(TYPE_STR,      REQ_YES'return ($data != \'\');'),
        
'pagetexted'    => array(TYPE_STR,      REQ_NO'return ($data != \'\');'),
        
'url'            => array(TYPE_STR,        REQ_NO'verify_link')
    );

    
/**
    * The main table this class deals with
    *
    * @var    string
    */
    
var $table 'scst_fb';

    
/**
    * Condition for update query
    *
    * @var    array
    */
    
var $condition_construct = array('fbid = %1$d''fbid');

    
/**
    * Constructor - checks that the registry object has been passed correctly.
    *
    * @param    vB_Registry    Instance of the vBulletin data registry object - expected to have the database object as one of its $this->db member.
    * @param    integer        One of the ERRTYPE_x constants
    */
    
function vB_DataManager_Feedback(&$registry$errtype ERRTYPE_STANDARD)
    {
        
parent::vB_DataManager($registry$errtype);

    }

    
/**
    * Verifies that the specified taskid is valid
    *
    * @param    integer    Task ID
    *
    * @return    boolean
    */
    
function verify_taskid(&$taskid)
    {
        
$db =& $this->registry->db;
        
        
$taskresult $db->query_first("SELECT FROM " TABLE_PREFIX "scst_task WHERE taskid = $taskid");
        
        if (
$taskid == $taskresult['taskid'])
        {
            return 
true;
        }
        else
        {
            
$this->error('invalid_task_specified');
            return 
false;
        }
    }

    
/**
    * Verifies that the specified eventid is valid
    *
    * @param    integer    Event ID
    *
    * @return    boolean
    */
    
function verify_eventid(&$eventid)
    {
        
$db =& $this->registry->db;
        
        
$eventresult $db->query_first("SELECT FROM " TABLE_PREFIX "scst_event WHERE eventid = $eventid");
        
        if (
$eventid == $eventresult['eventid'])
        {
            return 
true;
        }
        else
        {
            
$this->error('invalid_event_specified');
            return 
false;
        }
    }

    
/**
    * Any checks to run immediately before saving. If returning false, the save will not take place.
    *
    * @param    boolean    Do the query?
    *
    * @return    boolean    True on success; false if an error occurred
    */
    
function pre_save($doquery true)
    {
        if (
$this->presave_called !== null)
        {
            return 
$this->presave_called;
        }

        
$return_value true;

        
$this->presave_called $return_value;
        return 
$return_value;
    }

    
/**
    * Additional data to update after a delete call (such as denormalized values in other tables).
    *
    * @param    boolean    Do the query?
    */
    
function post_delete($doquery true)
    {
        
$fbid intval($this->existing['fbid']);
        
$db =& $this->registry->db;

        
$db->query_write("DELETE FROM " TABLE_PREFIX "scst_fbposts WHERE fbid = $fbid");

        return 
true;
    }

I think it has something to do with placing just the repeating data for each record for secondary table into an array within the var $children. Is that all I need to do then? Where do I identify the secondary var $table?

Reply With Quote
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01177 seconds
  • Memory Usage 1,860KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD_SHOWPOST
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_php
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)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)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • reputationlevel
  • showthread
Included Files:
  • ./showpost.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_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showpost_start
  • bbcode_fetch_tags
  • bbcode_create
  • postbit_factory
  • showpost_post
  • 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
  • showpost_complete