コード例 #1
0
 protected function addSimpleOperation(SimpleOperation $operation)
 {
     switch ($operation->getOperator()) {
         case Fetcher::TYPE_EQ:
             return array($operation->getColumnName() => array('$eq' => $operation->getValue()));
         case Fetcher::TYPE_IN:
             return array($operation->getColumnName() => array('$in' => $operation->getValue()));
         case Fetcher::TYPE_ARRAY_CONTAINS:
             return array($operation->getColumnName() => array('$all' => $operation->getValue()));
         case Fetcher::TYPE_ARRAY_LENGTH:
             return array($operation->getColumnName() => array('$size' => $operation->getValue()));
         case Fetcher::TYPE_ILIKE:
             return array($operation->getColumnName() => array('$regex' => preg_quote($operation->getValue()), '$options' => 'i'));
         case Fetcher::TYPE_LIKE:
             return array($operation->getColumnName() => array('$regex' => preg_quote($operation->getValue())));
         default:
             throw new \InvalidArgumentException(sprintf('Unsupported operation : %s !', $operation->getOperator()));
     }
 }
コード例 #2
0
 protected function getOperationValue(SimpleOperation $operation)
 {
     switch ($operation->getOperator()) {
         case Fetcher::TYPE_LIKE:
         case Fetcher::TYPE_ILIKE:
             return '%' . $operation->getValue() . '%';
         case Fetcher::TYPE_LOWERED_EQ:
             return strtolower($operation->getValue());
         default:
             return $operation->getValue();
     }
 }