From 272c1f8341bb62eba2723c5a15d3837074e26087 Mon Sep 17 00:00:00 2001 From: Jaap Jansma <jaap.jansma@civicoop.org> Date: Tue, 2 Jul 2019 14:58:32 +0200 Subject: [PATCH] Added an IsNull sql where clause --- .../SqlDataFlow/IsNullWhereClause.php | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 Civi/DataProcessor/DataFlow/SqlDataFlow/IsNullWhereClause.php diff --git a/Civi/DataProcessor/DataFlow/SqlDataFlow/IsNullWhereClause.php b/Civi/DataProcessor/DataFlow/SqlDataFlow/IsNullWhereClause.php new file mode 100644 index 00000000..f4783a6f --- /dev/null +++ b/Civi/DataProcessor/DataFlow/SqlDataFlow/IsNullWhereClause.php @@ -0,0 +1,47 @@ +<?php +/** + * @author Jaap Jansma <jaap.jansma@civicoop.org> + * @license AGPL-3.0 + */ + +namespace Civi\DataProcessor\DataFlow\SqlDataFlow; + +class IsNullWhereClause implements WhereClauseInterface { + + protected $table_alias; + + protected $field; + + protected $operator; + + protected $value; + + protected $isJoinClause = FALSE; + + public function __construct($table_alias, $field, $isJoinClause=FALSE) { + $this->isJoinClause = $isJoinClause; + $this->table_alias = $table_alias; + $this->field = $field; + } + + /** + * Returns true when this where clause can be added to the + * join or whether this clause should be propagated to the where part of the query + * + * @return bool + */ + public function isJoinClause() { + return $this->isJoinClause; + } + + /** + * Returns the where clause + * E.g. contact_type = 'Individual' + * + * @return string + */ + public function getWhereClause() { + return "`{$this->table_alias}`.`{$this->field}` IS NULL"; + } + +} \ No newline at end of file -- GitLab