Why are all the fields in TASKS selected here when I am only asking for id? This is my code
<?php /** * @param string $parent_id * @param string $type * @param array $status * @param string $subject * @param bool $billing * @return bool|false|string */ function checkForTask(string $parent_id, $type = 'Order Master', $status = array(), $subject = '', $billing = false) { try { $query = new SugarQuery(); $from = $query->from(BeanFactory::newBean('Tasks'), IGNORE_TEAMS)->getFromAlias(); $query->select(array("{$from}.id")); $query->where()->equals('task_type_c', $type); if ($billing) { $tasks = $query->join('tasks_tasks_1', IGNORE_TEAMS)->joinName(); $query->where()->equals("{$tasks}.id", $parent_id); } else { $query->where()->equals('parent_id', $parent_id); } if (!empty($status)) { $query->where()->notIn('status', $status); } if (!empty($subject)) { $query->where()->equals('name', $subject); } $id = $query->getOne(); if (empty($id)) { return false; } else { return $id; } } catch (SugarQueryException $e) { $GLOBALS['log']->fatal(print_r($e, true)); return false; } }