/** * method supporting recursion through all criterions to give * us an array of them * @param Criterion $c * @param array &$a * @return void */ private function traverseCriterion(Criterion $c, &$a) { $a[] = $c; foreach ($c->getClauses() as $clause) { $this->traverseCriterion($clause, $a); } }
/** * method supporting recursion through all criterions to give * us an array of them * @param Criterion $c * @param array &$a * @return void */ private function traverseCriterion(Criterion $c, &$a) { $a[] = $c; $clauses = $c->getClauses(); $clausesLength = count($clauses); for ($i = 0; $i < $clausesLength; $i++) { $this->traverseCriterion($clauses[$i], $a); } }
/** * method supporting recursion through all criterions to give * us a string array of tables from each criterion * @return void */ private function addCriterionTable(Criterion $c, array &$s) { $s[] = $c->getTable(); foreach ($c->getClauses() as $clause) { $this->addCriterionTable($clause, $s); } }
/** * add inner criteria for criterions * ----------------- IMPORTANT ----------------- * for this to work - we have to change the access modifier of the Creterion::getClauses() function from private to public * It's in the Criteria.php file under * /symfony/vendor/propel/util/Criteria.php */ private function addClauses(Criteria $criteria_to_filter, Criterion $filter_criterion, Criterion $crit) { $conjunctions = $filter_criterion->getConjunctions(); if (count($conjunctions) < 1) { return; } $clauses = $filter_criterion->getClauses(); $i = 0; foreach ($clauses as $clause) { $new_crit = $criteria_to_filter->getNewCriterion($clause->getTable() . "." . $clause->getColumn(), $clause->getValue(), $clause->getComparison()); $conj = @$conjunctions[$i]; if ($conj == Criterion::UND) { $crit->addAnd($new_crit); } elseif ($conj == Criterion::ODER) { $crit->addOr($new_crit); } $i++; } }
private function _createSqlFromCriterion(Criterion $aCriterion) { //var_dump( $aCriterion ); //$this->_hidden_criterion->getTable() // echo $aCriterion->getColumn(); // echo $aCriterion->getValue(); // echo $aCriterion->getComparison(); // var_dump( $aCriterion->getAllTables() ); // var_dump( $aCriterion->getAttachedCriterion() ); // var_dump( $aCriterion->getTable() ); $table = $aCriterion->getTable() ? $aCriterion->getTable() . '.' : ''; $value = $aCriterion->getValue(); if (is_array($value)) { foreach ($value as $key => $val) { $value[$key] = "'" . chks($val) . "'"; } if (count($value)) { $value = '(' . implode(',', $value) . ')'; } else { $value = '( NULL )'; } } else { if (!is_null($value) && !is_numeric($value)) { $value = "'" . chks($value) . "'"; } } if (is_null($value)) { if (self::EQUAL == $aCriterion->getComparison() || self::ISNULL == $aCriterion->getComparison() || self::IN == $aCriterion->getComparison()) { $partWhere = trim($table . $aCriterion->getColumn(), '.') . " IS NULL"; } else { $partWhere = trim($table . $aCriterion->getColumn(), '.') . " IS NOT NULL"; } } else { $partWhere = trim($table . $aCriterion->getColumn(), '.') . $aCriterion->getComparison() . $value; } $clauses = $aCriterion->getClauses(); if (is_array($clauses) && count($clauses)) { $conjunctions = $aCriterion->getConjunctions(); for ($i = 0; $i < count($clauses); $i++) { $partWhere = '(' . $partWhere . ')' . $conjunctions[$i] . $this->_createSqlFromCriterion($clauses[$i]); } } return $partWhere; }
/** * add inner criteria for criterions * ----------------- IMPORTANT ----------------- * for this to work - we have to change the access modifier of the Creterion::getClauses() function from private to public * It's in the Criteria.php file under * /symfony/vendor/propel/util/Criteria.php */ private function addClauses(Criteria $criteriaToFilter, Criterion $filterCriterion, Criterion $criterion) { $conjunctions = $filterCriterion->getConjunctions(); if (count($conjunctions) < 1) { return; } $clauses = $filterCriterion->getClauses(); $i = 0; foreach ($clauses as $clause) { if ($clause instanceof KalturaCriterion && !$clause->isEnabled()) { continue; } /* @var $clause Criterion */ $newCriterion = $criteriaToFilter->getNewCriterion($clause->getTable() . "." . $clause->getColumn(), $clause->getValue(), $clause->getComparison()); $conj = @$conjunctions[$i]; if ($conj == Criterion::UND) { $criterion->addAnd($newCriterion); } elseif ($conj == Criterion::ODER) { $criterion->addOr($newCriterion); } $i++; } }