Merge pull request #18704 from mlutfy/partListingOutput
[civicrm-core.git] / CRM / Contact / BAO / Household.php
CommitLineData
6a488035
TO
1<?php
2/*
3 +--------------------------------------------------------------------+
bc77d7c0 4 | Copyright CiviCRM LLC. All rights reserved. |
6a488035 5 | |
bc77d7c0
TO
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
6a488035 9 +--------------------------------------------------------------------+
d25dd0ee 10 */
6a488035
TO
11
12/**
13 *
14 * @package CRM
ca5cec67 15 * @copyright CiviCRM LLC https://civicrm.org/licensing
6a488035
TO
16 */
17class CRM_Contact_BAO_Household extends CRM_Contact_DAO_Contact {
18
19 /**
67d19299 20 * Class constructor.
6a488035 21 */
00be9182 22 public function __construct() {
6a488035
TO
23 parent::__construct();
24 }
25
26 /**
fe482240 27 * Update the household with primary contact id.
6a488035 28 *
77c5b619
TO
29 * @param int $primaryContactId
30 * Null if deleting primary contact.
31 * @param int $contactId
32 * Contact id.
6a488035 33 *
a6c01b45
CW
34 * @return Object
35 * DAO object on success
6a488035 36 */
00be9182 37 public static function updatePrimaryContact($primaryContactId, $contactId) {
6a488035
TO
38 $queryString = "UPDATE civicrm_contact
39 SET primary_contact_id = ";
40
be2fb01f 41 $params = [];
6a488035
TO
42 if ($primaryContactId) {
43 $queryString .= '%1';
be2fb01f 44 $params[1] = [$primaryContactId, 'Integer'];
6a488035
TO
45 }
46 else {
47 $queryString .= "null";
48 }
49
50 $queryString .= " WHERE id = %2";
be2fb01f 51 $params[2] = [$contactId, 'Integer'];
6a488035
TO
52
53 return CRM_Core_DAO::executeQuery($queryString, $params);
54 }
96025800 55
6a488035 56}