Merge pull request #22264 from sunilpawar/dev_recurring_error
[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 * Update the household with primary contact id.
21 *
22 * @param int $primaryContactId
23 * Null if deleting primary contact.
24 * @param int $contactId
25 * Contact id.
26 *
27 * @return Object
28 * DAO object on success
29 */
30 public static function updatePrimaryContact($primaryContactId, $contactId) {
31 $queryString = "UPDATE civicrm_contact
32 SET primary_contact_id = ";
33
34 $params = [];
35 if ($primaryContactId) {
36 $queryString .= '%1';
37 $params[1] = [$primaryContactId, 'Integer'];
38 }
39 else {
40 $queryString .= "null";
41 }
42
43 $queryString .= " WHERE id = %2";
44 $params[2] = [$contactId, 'Integer'];
45
46 return CRM_Core_DAO::executeQuery($queryString, $params);
47 }
48
49 }