/** * Instantiates a new instance of this object from a string * * @param String $string The string to parse into an object * @return \r8\Query\Atom\Field */ public static function fromString($string) { $parsed = \r8\Query::parseSQLName($string); $field = new self(array_pop($parsed)); if (count($parsed) > 0) { $field->setTable(array_pop($parsed)); } if (count($parsed) > 0) { $field->setDatabase(array_pop($parsed)); } return $field; }
/** * Instantiates a new instance of this object from a string * * @param String $string The string to parse into an object * @return \r8\Query\From\Table */ public static function fromString($string) { list($string, $alias) = \r8\Query::parseSQLAlias($string); // Split the name into the table and database $parsed = \r8\Query::parseSQLName($string); // Instantiate with the table name $field = new self(array_pop($parsed)); // Set the database if we found one if (count($parsed) > 0) { $field->setDatabase(array_pop($parsed)); } // Now load in the alias if ($alias) { $field->setAlias($alias); } return $field; }
public function testSelect() { $this->assertThat(\r8\Query::select(), $this->isInstanceOf('\\r8\\Query\\Select')); }
/** * Instantiates a new instance of this object from a string * * @param String $string The string to parse into an object * @return \r8\Query\Expr\Aliased */ public static function fromString($string) { list($string, $alias) = \r8\Query::parseSQLAlias($string); $atom = \r8\Query\Atom\Field::fromString($string); return new self($atom, $alias); }
public function testFluent() { $select = \r8\Query::select()->distinct()->fields("fld1", "db.fld2 AS info")->from("db.tableName")->where("`fld1` = 5")->orderBy("sortField DESC")->groupBy("id")->having("COUNT(*) = 2")->limit(20, 100); $link = new \r8\DB\Link(new \r8\DB\BlackHole\Link()); $this->assertSame("SELECT DISTINCT `fld1`, db.`fld2` AS `info`\n" . "FROM db.`tableName`\n" . "WHERE `fld1` = 5\n" . "ORDER BY `sortField` DESC\n" . "GROUP BY id\n" . "HAVING COUNT(*) = 2\n" . "LIMIT 100, 20", $select->toSQL($link)); }