Exemple #1
0
 protected function _argToCondition($arg)
 {
     if (!$arg instanceof Condition) {
         $arg = Condition::create($arg);
         if ($this->_prefix) {
             $arg->setPrefix($this->_prefix);
         }
     }
     return $arg;
 }
Exemple #2
0
 public static function createSelectParams($condition = null, $order = null, $limit = null)
 {
     $sql = "";
     if (!is_null($condition)) {
         $sql .= " WHERE " . Condition::create($condition)->toSql();
     } else {
         $sql .= " WHERE 1";
     }
     if ($order) {
         $sql .= " ORDER BY " . Helper::orderToSql($order);
     }
     if ($limit) {
         $sql .= " LIMIT " . Helper::limitToSql($limit);
     }
     return $sql;
 }
Exemple #3
0
 public static function _select($condition = null, $order = null, $limit = null)
 {
     if (is_null(self::$_preloaded)) {
         self::$_preloaded = parent::_select();
     }
     //TODO: $order & $limit processing
     if (is_null($condition)) {
         return self::$_preloaded;
     }
     $condition = Condition::create($condition);
     $resultSet = [];
     foreach (self::$_preloaded as $entry) {
         if ($condition->test($entry)) {
             $resultSet[] = $entry;
         }
     }
     return $resultSet;
 }
Exemple #4
0
 public function testOrAndOrCondition()
 {
     $st = MODEL("SchemaTest");
     $or1 = new Sabel_Db_Condition_Or();
     $or1->add(Condition::create(EQUAL, "sint", 100));
     $or1->add(Condition::create(EQUAL, "sint", 300));
     $or2 = new Sabel_Db_Condition_Or();
     $or2->add(Condition::create(EQUAL, "sint", 300));
     $or2->add(Condition::create(EQUAL, "sint", 500));
     $st->setOrderBy("id");
     $st->setCondition($or1);
     $st->setCondition($or2);
     $results = $st->select();
     $this->assertEquals(2, count($results));
     $this->assertEquals("*****@*****.**", $results[0]->email);
     $this->assertEquals("*****@*****.**", $results[1]->email);
 }
Exemple #5
0
 /**
  * @param $condition
  * @return bool
  */
 public function isMatch($condition)
 {
     return Condition::create($condition)->test($this->_fields);
 }