function getByCompanyIDAndObjectTypeAndObjectID($company_id, $object_type_id, $id, $where = NULL, $order = NULL) { if ($company_id == '') { return FALSE; } if ($object_type_id == '') { return FALSE; } if ($id == '') { return FALSE; } $additional_order_fields = array('cgtf.name'); if ($order == NULL) { $order = array('cgtf.name' => 'asc'); $strict = FALSE; } else { $strict = TRUE; } $cgtf = new CompanyGenericTagFactory(); $ph = array('company_id' => $company_id); //This should be a list of just distinct $query = ' select a.*, cgtf.name as name from ' . $this->getTable() . ' as a LEFT JOIN ' . $cgtf->getTable() . ' as cgtf ON ( a.object_type_id = cgtf.object_type_id AND a.tag_id = cgtf.id AND cgtf.company_id = ?) where a.object_type_id in (' . $this->getListSQL($object_type_id, $ph) . ') AND a.object_id in (' . $this->getListSQL($id, $ph) . ') '; $query .= $this->getWhereSQL($where); $query .= $this->getSortSQL($order, $strict, $additional_order_fields); $this->ExecuteSQL($query, $ph); return $this; }