5 * @copyright CiviCRM LLC https://civicrm.org/licensing
7 * Generated from xml/schema/CRM/Contact/SavedSearch.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:bca384578ea59c0cf4f0a80617c788fe)
13 * Database access object for the SavedSearch entity.
15 class CRM_Contact_DAO_SavedSearch
extends CRM_Core_DAO
{
16 const EXT
= 'civicrm';
17 const TABLE_ADDED
= '1.1';
20 * Static instance to hold the table name.
24 public static $_tableName = 'civicrm_saved_search';
27 * Should CiviCRM log any modifications to this table in the civicrm_log table.
31 public static $_log = FALSE;
41 * Unique name of saved search
48 * Administrative label for search
55 * Submitted form values for this search
62 * Foreign key to civicrm_mapping used for saved search-builder searches.
69 * Foreign key to civicrm_option value table used for saved custom searches.
73 public $search_custom_id;
76 * Entity name for API based search
83 * Parameters for API based search
90 * FK to contact table.
97 * FK to contact table.
104 * Optional date after which the search is not needed
108 public $expires_date;
111 * When the search was created.
115 public $created_date;
118 * When the search was last modified.
122 public $modified_date;
132 public function __construct() {
133 $this->__table
= 'civicrm_saved_search';
134 parent
::__construct();
138 * Returns localized title of this entity.
140 * @param bool $plural
141 * Whether to return the plural version of the title.
143 public static function getEntityTitle($plural = FALSE) {
144 return $plural ?
ts('Saved Searches') : ts('Saved Search');
148 * Returns foreign keys and entity references.
151 * [CRM_Core_Reference_Interface]
153 public static function getReferenceColumns() {
154 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
155 Civi
::$statics[__CLASS__
]['links'] = static::createReferenceColumns(__CLASS__
);
156 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'mapping_id', 'civicrm_mapping', 'id');
157 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'created_id', 'civicrm_contact', 'id');
158 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'modified_id', 'civicrm_contact', 'id');
159 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
161 return Civi
::$statics[__CLASS__
]['links'];
165 * Returns all the column names of this table
169 public static function &fields() {
170 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
171 Civi
::$statics[__CLASS__
]['fields'] = [
174 'type' => CRM_Utils_Type
::T_INT
,
175 'title' => ts('Saved Search ID'),
176 'description' => ts('Saved Search ID'),
178 'where' => 'civicrm_saved_search.id',
179 'table_name' => 'civicrm_saved_search',
180 'entity' => 'SavedSearch',
181 'bao' => 'CRM_Contact_BAO_SavedSearch',
191 'type' => CRM_Utils_Type
::T_STRING
,
192 'title' => ts('Saved Search Name'),
193 'description' => ts('Unique name of saved search'),
195 'size' => CRM_Utils_Type
::HUGE
,
196 'where' => 'civicrm_saved_search.name',
198 'table_name' => 'civicrm_saved_search',
199 'entity' => 'SavedSearch',
200 'bao' => 'CRM_Contact_BAO_SavedSearch',
209 'type' => CRM_Utils_Type
::T_STRING
,
210 'title' => ts('Saved Search Label'),
211 'description' => ts('Administrative label for search'),
213 'size' => CRM_Utils_Type
::HUGE
,
214 'where' => 'civicrm_saved_search.label',
216 'table_name' => 'civicrm_saved_search',
217 'entity' => 'SavedSearch',
218 'bao' => 'CRM_Contact_BAO_SavedSearch',
222 'label' => ts("Label"),
227 'name' => 'form_values',
228 'type' => CRM_Utils_Type
::T_TEXT
,
229 'title' => ts('Submitted Form Values'),
230 'description' => ts('Submitted form values for this search'),
232 'where' => 'civicrm_saved_search.form_values',
234 'table_name' => 'civicrm_saved_search',
235 'entity' => 'SavedSearch',
236 'bao' => 'CRM_Contact_BAO_SavedSearch',
238 'serialize' => self
::SERIALIZE_PHP
,
242 'name' => 'mapping_id',
243 'type' => CRM_Utils_Type
::T_INT
,
244 'title' => ts('Mapping ID'),
245 'description' => ts('Foreign key to civicrm_mapping used for saved search-builder searches.'),
246 'where' => 'civicrm_saved_search.mapping_id',
247 'table_name' => 'civicrm_saved_search',
248 'entity' => 'SavedSearch',
249 'bao' => 'CRM_Contact_BAO_SavedSearch',
251 'FKClassName' => 'CRM_Core_DAO_Mapping',
253 'label' => ts("Mapping"),
257 'search_custom_id' => [
258 'name' => 'search_custom_id',
259 'type' => CRM_Utils_Type
::T_INT
,
260 'title' => ts('Option Value ID'),
261 'description' => ts('Foreign key to civicrm_option value table used for saved custom searches.'),
262 'where' => 'civicrm_saved_search.search_custom_id',
263 'table_name' => 'civicrm_saved_search',
264 'entity' => 'SavedSearch',
265 'bao' => 'CRM_Contact_BAO_SavedSearch',
270 'name' => 'api_entity',
271 'type' => CRM_Utils_Type
::T_STRING
,
272 'title' => ts('Entity Name'),
273 'description' => ts('Entity name for API based search'),
275 'size' => CRM_Utils_Type
::HUGE
,
276 'where' => 'civicrm_saved_search.api_entity',
277 'table_name' => 'civicrm_saved_search',
278 'entity' => 'SavedSearch',
279 'bao' => 'CRM_Contact_BAO_SavedSearch',
281 'pseudoconstant' => [
282 'callback' => 'CRM_Contact_BAO_SavedSearch::getApiEntityOptions',
287 'name' => 'api_params',
288 'type' => CRM_Utils_Type
::T_TEXT
,
289 'title' => ts('API Parameters'),
290 'description' => ts('Parameters for API based search'),
291 'where' => 'civicrm_saved_search.api_params',
292 'table_name' => 'civicrm_saved_search',
293 'entity' => 'SavedSearch',
294 'bao' => 'CRM_Contact_BAO_SavedSearch',
296 'serialize' => self
::SERIALIZE_JSON
,
300 'name' => 'created_id',
301 'type' => CRM_Utils_Type
::T_INT
,
302 'title' => ts('Created By Contact ID'),
303 'description' => ts('FK to contact table.'),
304 'where' => 'civicrm_saved_search.created_id',
305 'table_name' => 'civicrm_saved_search',
306 'entity' => 'SavedSearch',
307 'bao' => 'CRM_Contact_BAO_SavedSearch',
309 'FKClassName' => 'CRM_Contact_DAO_Contact',
311 'label' => ts("Created By"),
317 'name' => 'modified_id',
318 'type' => CRM_Utils_Type
::T_INT
,
319 'title' => ts('Modified By Contact ID'),
320 'description' => ts('FK to contact table.'),
321 'where' => 'civicrm_saved_search.modified_id',
322 'table_name' => 'civicrm_saved_search',
323 'entity' => 'SavedSearch',
324 'bao' => 'CRM_Contact_BAO_SavedSearch',
326 'FKClassName' => 'CRM_Contact_DAO_Contact',
328 'label' => ts("Modified By"),
334 'name' => 'expires_date',
335 'type' => CRM_Utils_Type
::T_TIMESTAMP
,
336 'title' => ts('Search Expiry Date'),
337 'description' => ts('Optional date after which the search is not needed'),
339 'where' => 'civicrm_saved_search.expires_date',
340 'table_name' => 'civicrm_saved_search',
341 'entity' => 'SavedSearch',
342 'bao' => 'CRM_Contact_BAO_SavedSearch',
347 'name' => 'created_date',
348 'type' => CRM_Utils_Type
::T_TIMESTAMP
,
349 'title' => ts('Created Date'),
350 'description' => ts('When the search was created.'),
352 'where' => 'civicrm_saved_search.created_date',
353 'default' => 'CURRENT_TIMESTAMP',
354 'table_name' => 'civicrm_saved_search',
355 'entity' => 'SavedSearch',
356 'bao' => 'CRM_Contact_BAO_SavedSearch',
362 'name' => 'modified_date',
363 'type' => CRM_Utils_Type
::T_TIMESTAMP
,
364 'title' => ts('Modified Date'),
365 'description' => ts('When the search was last modified.'),
367 'where' => 'civicrm_saved_search.modified_date',
368 'default' => 'CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP',
369 'table_name' => 'civicrm_saved_search',
370 'entity' => 'SavedSearch',
371 'bao' => 'CRM_Contact_BAO_SavedSearch',
377 'name' => 'description',
378 'type' => CRM_Utils_Type
::T_TEXT
,
379 'title' => ts('Saved Search Description'),
382 'where' => 'civicrm_saved_search.description',
383 'table_name' => 'civicrm_saved_search',
384 'entity' => 'SavedSearch',
385 'bao' => 'CRM_Contact_BAO_SavedSearch',
388 'type' => 'TextArea',
393 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
395 return Civi
::$statics[__CLASS__
]['fields'];
399 * Return a mapping from field-name to the corresponding key (as used in fields()).
402 * Array(string $name => string $uniqueName).
404 public static function &fieldKeys() {
405 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
406 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
408 return Civi
::$statics[__CLASS__
]['fieldKeys'];
412 * Returns the names of this table
416 public static function getTableName() {
417 return self
::$_tableName;
421 * Returns if this table needs to be logged
425 public function getLog() {
430 * Returns the list of fields that can be imported
432 * @param bool $prefix
436 public static function &import($prefix = FALSE) {
437 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'saved_search', $prefix, []);
442 * Returns the list of fields that can be exported
444 * @param bool $prefix
448 public static function &export($prefix = FALSE) {
449 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'saved_search', $prefix, []);
454 * Returns the list of indices
456 * @param bool $localize
460 public static function indices($localize = TRUE) {
467 'localizable' => FALSE,
469 'sig' => 'civicrm_saved_search::1::name',
472 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;