コード例 #1
0
ファイル: Is_Greatest.php プロジェクト: TuxBoy/Demo-saf
 /**
  * Returns the Dao function as SQL
  *
  * @param $builder       Builder\Where the sql query builder
  * @param $property_path string the property path
  * @param $prefix        string
  * @return string
  */
 public function toSql(Builder\Where $builder, $property_path, $prefix = '')
 {
     $joins = $builder->getJoins();
     // sub-query
     $class_name = $joins->getStartingClassName();
     $properties = $this->properties + [$property_path => Func::max()];
     $sub_builder = new Builder\Select($class_name, $properties, null, $builder->getSqlLink(), [Dao::groupBy($this->properties)]);
     // join
     $join = new Subquery($sub_builder);
     $joins->addJoin($join);
     // where
     $where = '';
     foreach (array_merge($this->properties, [$property_path]) as $property) {
         $where .= ' AND ' . $join->foreign_alias . DOT . BQ . rLastParse($property, DOT, 1, true) . BQ . ' = ' . $builder->buildColumn($property, $prefix);
     }
     $join->where = substr($where, 5);
     return null;
 }
コード例 #2
0
ファイル: Count.php プロジェクト: TuxBoy/Demo-saf
 /**
  * @return Joins
  */
 public function getJoins()
 {
     return $this->where_builder->getJoins();
 }