Example #1
0
    /**
     * Deletes an associated AttributeValue
     * @param AttributeValue $objAttributeValue
     * @return void
     */
    public function DeleteAssociatedAttributeValue(AttributeValue $objAttributeValue)
    {
        if (is_null($this->intId)) {
            throw new QUndefinedPrimaryKeyException('Unable to call UnassociateAttributeValue on this unsaved Person.');
        }
        if (is_null($objAttributeValue->Id)) {
            throw new QUndefinedPrimaryKeyException('Unable to call UnassociateAttributeValue on this Person with an unsaved AttributeValue.');
        }
        // Get the Database Object for this Class
        $objDatabase = Person::GetDatabase();
        // Perform the SQL Query
        $objDatabase->NonQuery('
				DELETE FROM
					`attribute_value`
				WHERE
					`id` = ' . $objDatabase->SqlVariable($objAttributeValue->Id) . ' AND
					`person_id` = ' . $objDatabase->SqlVariable($this->intId) . '
			');
        // Journaling
        if ($objDatabase->JournalingDatabase) {
            $objAttributeValue->Journal('DELETE');
        }
    }