public function testOperatorIsMutable() { $operator = new Operator(); $operator->setOperator(Operator::OP_LTE); $this->assertEquals(Operator::OP_LTE, $operator->getOperator()); }
protected function convertValues($type, $data) { $type = strtoupper($type); $return = array(); switch ($type) { case self::WHERE: //'string' //array('object') //array('string' => 'object') $association = $data[0]; $data = $data[1]; if (is_array($data)) { foreach ($data as $k1 => $v1) { if (is_int($k1)) { $value = $this->convertValues($type, $v1); $return = array_merge($return, $value); } else { $predicate = new Operator(); $predicate->setOperator('='); $predicate->setLeft(trim($k1)); $predicate->setRight(new Predicate\Expression(':value' . $this->getKeyValues())); $this->setFactoryValues(self::VALUES, array(':value' . $this->getKeyValues() => $v1)); $this->setKeyValues($this->getKeyValues() + 1); array_push($return, $predicate); } } } else { if (is_object($data)) { array_push($return, array($data, $association)); } else { $predicate = new Operator(); $operator = $this->extractOperator($data); $data = explode($operator, $data); $predicate->setOperator($operator); $predicate->setLeft(trim($data[0])); $predicate->setRight(new Predicate\Expression(':value' . $this->getKeyValues())); $this->setFactoryValues(self::VALUES, array(':value' . $this->getKeyValues() => trim($data[1]))); $this->setKeyValues($this->getKeyValues() + 1); array_push($return, array($predicate, $association)); } } return $return; break; case self::COLUMNS: $return = $data; if (is_object($data)) { $return = array($return); } return $return; break; case self::FROM: $return = $data; if (is_object($data)) { $return = array($return); } return $return; break; case self::UPDATE: if (is_array($data)) { foreach ($data as $k1 => $v1) { if (is_int($k1)) { $value = $this->convertValues($type, $v1); array_push($return, $value); } else { $expression = new Predicate\Expression(':value' . $this->getKeyValues()); $this->setFactoryValues(self::VALUES, array(':value' . $this->getKeyValues() => $v1)); $this->setKeyValues($this->getKeyValues() + 1); array_push($return, array($k1 => $expression)); } } } else { if (is_object($data)) { $return = array($data); } else { $expression = new Predicate\Expression(':value' . $this->getKeyValues()); $this->setFactoryValues(self::VALUES, array(':value' . $this->getKeyValues() => $data)); $this->setKeyValues($this->getKeyValues() + 1); $return = $expression; } } return $return; break; case self::INSERT: if (is_array($data)) { foreach ($data as $k1 => $v1) { if (is_int($k1)) { $value = $this->convertValues($type, $v1); array_push($return, $value); } else { $expression = new Predicate\Expression(':value' . $this->getKeyValues()); $this->setFactoryValues(self::VALUES, array(':value' . $this->getKeyValues() => $v1)); $this->setKeyValues($this->getKeyValues() + 1); array_push($return, array($k1 => $expression)); } } } else { if (is_object($data)) { $return = array($data); } else { $expression = new Predicate\Expression(':value' . $this->getKeyValues()); $this->setFactoryValues(self::VALUES, array(':value' . $this->getKeyValues() => $data)); $this->setKeyValues($this->getKeyValues() + 1); $return = $expression; } } return $return; break; case self::IS_NULL: $return = array(); if (is_array($data)) { foreach ($data as $array) { foreach ($array as $key => $value) { array_push($return, new isNull(trim($value))); } } } return $return; break; case self::IS_NOT_NULL: $return = array(); if (is_array($data)) { foreach ($data as $array) { foreach ($array as $key => $value) { array_push($return, new isNotNull(trim($value))); } } } return $return; break; } }