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_YES, VF_METHOD),
'taskid' => array(TYPE_UINT, REQ_YES, VF_METHOD),
'eventid' => array(TYPE_UINT, REQ_YES, VF_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_YES, VF_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_UNIXTIME, REQ_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?