/** * Given a table and id pair, return the filter clause * * @param string $table - The table owning the object * @param int $id - The ID of the object * @param array ref $tables - Tables that will be needed in the FROM * * @return string|null - WHERE-style clause to filter results, or null if $table or $id is null * @access public * @static */ public static function getClause($table, $id, &$tables) { $table = CRM_Utils_Type::escape($table, 'String'); $id = CRM_Utils_Type::escape($id, 'Integer'); $whereTables = array(); $ssTable = CRM_Contact_BAO_SavedSearch::getTableName(); if (empty($table)) { return NULL; } elseif ($table == $ssTable) { return CRM_Contact_BAO_SavedSearch::whereClause($id, $tables, $whereTables); } elseif (!empty($id)) { $tables[$table] = TRUE; return "{$table}.id = {$id}"; } return NULL; }