Merge pull request #18704 from mlutfy/partListingOutput
[civicrm-core.git] / CRM / Contact / BAO / Household.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
5 | |
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 |
9 +--------------------------------------------------------------------+
10 */
11
12 /**
13 *
14 * @package CRM
15 * @copyright CiviCRM LLC https://civicrm.org/licensing
16 */
17 class CRM_Contact_BAO_Household extends CRM_Contact_DAO_Contact {
18
19 /**
20 * Class constructor.
21 */
22 public function __construct() {
23 parent::__construct();
24 }
25
26 /**
27 * Update the household with primary contact id.
28 *
29 * @param int $primaryContactId
30 * Null if deleting primary contact.
31 * @param int $contactId
32 * Contact id.
33 *
34 * @return Object
35 * DAO object on success
36 */
37 public static function updatePrimaryContact($primaryContactId, $contactId) {
38 $queryString = "UPDATE civicrm_contact
39 SET primary_contact_id = ";
40
41 $params = [];
42 if ($primaryContactId) {
43 $queryString .= '%1';
44 $params[1] = [$primaryContactId, 'Integer'];
45 }
46 else {
47 $queryString .= "null";
48 }
49
50 $queryString .= " WHERE id = %2";
51 $params[2] = [$contactId, 'Integer'];
52
53 return CRM_Core_DAO::executeQuery($queryString, $params);
54 }
55
56 }