private function loadTaxonomyNodeLabels() { $IN_nodeIds = $this->db->in('tax_node.obj_id', $this->taxonomyNodeIds, false, 'integer'); $query = "\n\t\t\t\t\tSELECT\t\ttax_node.obj_id tax_node_id,\n\t\t\t\t\t\t\t\ttax_node.title tax_node_title\n\n\t\t\t\t\tFROM\t\ttax_node\n\n\t\t\t\t\tWHERE\t\t{$IN_nodeIds}\n\t\t\t\t"; $res = $this->db->query($query); while ($row = $this->db->fetchAssoc($res)) { $this->taxonomyNodeLabels[$row['tax_node_id']] = $row['tax_node_title']; } }
private function getPurgableQuestionIds() { $INtypes = $this->db->in('object_data.type', $this->getIgnoredContainerObjectTypes(), true, 'text'); $query = "\n\t\t\tSELECT qpl_questions.question_id\n\t\t\tFROM qpl_questions\n\t\t\tINNER JOIN object_data\n\t\t\tON object_data.obj_id = qpl_questions.obj_fi\n\t\t\tAND {$INtypes}\n\t\t\tWHERE qpl_questions.owner = %s\n\t\t\tAND qpl_questions.tstamp = %s\n\t\t"; $res = $this->db->queryF($query, array('integer', 'integer'), array($this->getOwnerId(), 0)); $questionIds = array(); while ($row = $this->db->fetchAssoc($res)) { $questionIds[] = $row['question_id']; } return $questionIds; }
private function getActiveIds() { if (!count($this->getTestObjIds())) { return null; } $inTestObjIds = $this->db->in('obj_fi', $this->getTestObjIds(), false, 'integer'); $res = $this->db->query("\n\t\t\tSELECT active_id\n\t\t\tFROM tst_tests\n\t\t\tINNER JOIN tst_active\n\t\t\tON test_fi = test_id\n\t\t\tWHERE {$inTestObjIds}\n\t\t"); $activeIds = array(); while ($row = $this->db->fetchAssoc($res)) { $activeIds[] = $row['active_id']; } return $activeIds; }
public function getConditionalExpression() { $conditions = array(); if (count($this->getActiveIds())) { $conditions[] = $this->db->in('active_id', $this->getActiveIds(), false, 'integer'); } if (count($this->getUserIds())) { $conditions[] = $this->db->in('user_fi', $this->getUserIds(), false, 'integer'); } if (count($conditions)) { return '(' . implode(' OR ', $conditions) . ')'; } return '1 = 1'; }
private function getTaxonomyFilterExpressions() { $expressions = array(); require_once 'Services/Taxonomy/classes/class.ilTaxonomyTree.php'; require_once 'Services/Taxonomy/classes/class.ilTaxNodeAssignment.php'; foreach ($this->getTaxonomyFilters() as $taxId => $taxNodes) { $questionIds = array(); $forceBypass = true; foreach ($taxNodes as $taxNode) { $forceBypass = false; $taxTree = new ilTaxonomyTree($taxId); $taxNodeAssignment = new ilTaxNodeAssignment('tst', $this->getTestObjId(), 'quest', $taxId); $subNodes = $taxTree->getSubTreeIds($taxNode); $subNodes[] = $taxNode; $taxItems = $taxNodeAssignment->getAssignmentsOfNode($subNodes); foreach ($taxItems as $taxItem) { $questionIds[$taxItem['item_id']] = $taxItem['item_id']; } } if (!$forceBypass) { $expressions[] = $this->db->in('question_id', $questionIds, false, 'integer'); } } return $expressions; }
/** * @param $title "employee" or "superior" * @param $ref_ids int[] array of orgu object ref ids. * @return int[] user_ids */ private function loadArrayOfStaff($title, $ref_ids) { $this->loadRoles($title); $all_refs = $ref_ids; //take away ref_ids that are already loaded. foreach ($ref_ids as $id => $ref_id) { if (isset($this->staff[$title][$ref_id])) { unset($ref_ids[$id]); } else { $this->staff[$title][$ref_id] = array(); $ref_ids[$id] = $this->roles[$title][$ref_id]; } } //if there are still refs that need to be loaded, then do so. if (count($ref_ids)) { $q = "SELECT usr_id, rol_id FROM rbac_ua WHERE " . $this->db->in("rol_id", $ref_ids, false, "integer"); $set = $this->db->query($q); while ($res = $this->db->fetchAssoc($set)) { $orgu_ref = $this->role_to_orgu[$title][$res["rol_id"]]; $this->staff[$title][$orgu_ref][] = $res["usr_id"]; } } //collect * users. $all_users = array(); foreach ($all_refs as $ref) { $all_users = array_merge($all_users, $this->staff[$title][$ref]); } return $all_users; }
private function buildQuery() { $query = $this->buildBasicQuery() . "\n\t\t\t{$this->getConditionalFilterExpression()}\n\t\t"; if (count($this->getForcedQuestionIds())) { $query .= "\n\t\t\t\tUNION {$this->buildBasicQuery()}\n\t\t\t\tAND\t{$this->db->in('qpl_questions.question_id', $this->getForcedQuestionIds(), false, 'integer')}\n\t\t\t"; } return $query; }
private function removeQuestionsNotCheckedAnymore() { $NOT_IN_checkedQuestions = $this->db->in('question_fi', $this->alreadyCheckedQuestions, true, 'integer'); // BEGIN: FIX IN QUERY if ($NOT_IN_checkedQuestions == ' 1=2 ') { $NOT_IN_checkedQuestions = ' 1=1 '; } // END: FIX IN QUERY $query = "\n\t\t\tDELETE FROM tst_seq_qst_checked\n\t\t\tWHERE active_fi = %s\n\t\t\tAND pass = %s\n\t\t\tAND {$NOT_IN_checkedQuestions}\n\t\t"; $this->db->manipulateF($query, array('integer', 'integer'), array((int) $this->getActiveId(), 0)); }
/** * Overwritten implementation of <code>$ilDB->in</code> * to avoid ORA-01795 (maximum number of expressions in a list is 1000) * * This implementation rewrites the in clause to * <code>field IN (1,2,3,...,1000) OR field IN (1000,1001,...,2000)</code> * * Example: * $ids = array(10,12,18); * $st = $ilDB->prepare("SELECT * FROM table ". * "WHERE ".$ilDB->in("id", $ids), * $ilDB->addTypesToArray($types, "integer", count($ids))); * $set = $ilDB->execute($st, $ids); */ function in($a_field, $a_values, $negate = false, $a_type = "") { if (count($a_values) <= self::LIMIT_EXPRESSIONS_IN_LIST) { return parent::in($a_field, $a_values, $negate, $a_type); } $first = true; $concat = $negate ? ' AND ' : ' OR '; $in = '('; do { if (!$first) { $in .= $concat; } $first = false; $spliced = array_splice($a_values, 0, self::LIMIT_EXPRESSIONS_IN_LIST); $in .= parent::in($a_field, $spliced, $negate, $a_type); } while ($a_values); return $in . " ) "; }