Example #1
0
    /**
     * Unassociates all People
     * @return void
     */
    public function UnassociateAllPeople()
    {
        if (is_null($this->intId)) {
            throw new QUndefinedPrimaryKeyException('Unable to call UnassociateAllPersonArray on this unsaved CommunicationList.');
        }
        // Get the Database Object for this Class
        $objDatabase = CommunicationList::GetDatabase();
        // Journaling (if applicable)
        if ($objDatabase->JournalingDatabase) {
            $objResult = $objDatabase->Query('SELECT `person_id` AS associated_id FROM `communicationlist_person_assn` WHERE `communication_list_id` = ' . $objDatabase->SqlVariable($this->intId));
            while ($objRow = $objResult->GetNextRow()) {
                $this->JournalPersonAssociation($objRow->GetColumn('associated_id'), 'DELETE');
            }
        }
        // Perform the SQL Query
        $objDatabase->NonQuery('
				DELETE FROM
					`communicationlist_person_assn`
				WHERE
					`communication_list_id` = ' . $objDatabase->SqlVariable($this->intId) . '
			');
    }