Last DataWriter question (for now) -- Seriously

Use the individual verification functions referenced in _getFields() to verify that the incoming data is physically valid for database, and that all other checks that can be done in isolation are valid.

Following that, use _preSave() to do any checking where you need to compare multiple fields, or work with multiple fields simultaneously, or check a field against changeable environmental concerns.
 
OK, validation works (do almost everything in _preSave(); ). Only 1 problem: It's never rejects the tag (as that's my unique ID here) for being unique. It's always set as an update / insert and never rejects it... Here's the _verifyCode:

PHP:
	protected function _verifyBbCodeId(&$tagId)
	{
		$tag = strtolower($tagId);

		if (preg_match('/[^a-zA-Z0-9_]/', $tagId))
		{
			$this->error(new XenForo_Phrase('please_enter_an_id_using_only_alphanumeric'), 'tag');
			return false;
		}
		if($this->isUpdate())
		{
			Zend_Debug::dump($this);
			die;
		}
		if ($this->isInsert() || $tag != $this->getExisting('tag'))
		{
			$existing = $this->_getCustomBbCodeModel()->getCustomBbCodeById($tagId);
			Zend_Debug::dump($existing);
			die;
			if($existing)
			{
				$this->error(new XenForo_Phrase('bbcm_errorTagMustBeUnique'), 'tag');
				return false;
			}
		}

		return true;
	}
 
Okay... now I'm having an issue with a datawriter... This is my code in my program:
Code:
// this part works fine
	$dw = XenForo_DataWriter::create('EWRcarta_DataWriter_History');
	$dw->bulkSet(array(
		'page_id'    => $input['page_id'],
		'history_date' => $input['page_date'],
		'history_type' => $input['page_type'],
		'history_content' => $input['page_content'],
		'history_current' => '1',
	));
	$dw->save();
	$userID = $dw->get('user_id');
	$histID = $dw->get('history_id');
	$histIP = $this->getModelFromCache('XenForo_Model_Ip')->logIp($userID, 'wiki', $histID, 'update');

//this part doesn't work
	$dw = XenForo_DataWriter::create('EWRcarta_DataWriter_History');
	$dw->setExistingData(array('history_id' => $histID));
	$dw->set('history_ip', $histIP);
	$dw->save();

// echo to make sure history_id and history_ip are being set correctly...
	echo $dw->get('history_id')." - ".$dw->get('history_ip'); exit;

Since I added the echo at the end, which is properly outputting what it should... such as "121 - 55" that means things are being set... however when I look at my database, the history_ip is always 0 (which is the default). For some reason, it didn't store 55 in the database, even though the get is saying it did.
 
Bumping... can anyone help me figure out why my previous code isn't working?
 
To be honest we are not seeing anything obviously wrong with it.
 
I figured it out!

For some reason, the getUpdateCondition in my datawriter was set to false... oops.
 
Back
Top Bottom