/** * Magic method to build a query from scratch. * * @param string $type * @param array $args * @return Query */ public static function __callStatic($type, $args) { if (QuerySplitter::getQueryType($type) == null) { throw new \Exception("Unknown query type '{$type}'."); } list($expression, $flags) = $args + array(null, 0); if (is_array($expression)) { if ($flags & Query::_BACKQUOTE_OPTIONS) { foreach ($expression as &$field) { $field = QuerySplitter::backquote($field, $flags); } } $expression = join(', ', $expression); } else { if ($flags & Query::_BACKQUOTE_OPTIONS) { $expression = QuerySplitter::backquote($expression, $flags); } } return new self($type . (isset($expression) ? " {$expression}" : '')); }
public function testGetQueryType_Unknown() { $this->assertNull(QuerySplitter::getQueryType("something")); }