src/flowcode/ceibo/builder/QueryBuilder.php
public static function buildSelectRelation($relation, $mapperRelation) {
        $query = "";

        $fields = "";
        foreach ($mapperRelation->getPropertys() as $property) {
            $fields .= "c." . $property->getColumn() . ", ";
        }
        $fields = substr_replace($fields, "", -2);

        if ($relation->getCardinality() == Relation::$manyToMany) {
            $query = "select " . $fields . " from " . $mapperRelation->getTable() . " c ";
            $query .= "inner join " . $relation->getTable() . " nc on nc." . $relation->getForeignColumn() . " = c.id ";
            $query .= "where nc." . $relation->getLocalColumn() . " = :id";
        }
        if ($relation->getCardinality() == Relation::$oneToMany) {
            $query = "select " . $fields . " from " . $mapperRelation->getTable() . " c ";
            $query .= "where c." . $relation->getForeignColumn() . " = :id";
        }
        return $query;
    }
public static function buildSelectRelation($relation, $mapperRelation) {
        $query = "";

        $fields = "";
        foreach ($mapperRelation->getPropertys() as $property) {
            $fields .= "c." . $property->getColumn() . ", ";
        }
        $fields = substr_replace($fields, "", -2);

        if ($relation->getCardinality() == Relation::$manyToMany) {
            $query = "select " . $fields . " from " . $mapperRelation->getTable() . " c ";
            $query .= "inner join " . $relation->getTable() . " nc on nc." . $relation->getForeignColumn() . " = c.id ";
            $query .= "where nc." . $relation->getLocalColumn() . " = :id";
        }
        if ($relation->getCardinality() == Relation::$oneToMany) {
            $query = "select " . $fields . " from " . $mapperRelation->getTable() . " c ";
            $query .= "where c." . $relation->getForeignColumn() . " = :id";
        }
        return $query;
    }
public static function buildSelectRelation ( $ relation , $ mapperRelation ) { $ query = "" ; $ fields = "" ; foreach ( $ mapperRelation -> getPropertys ( ) as $ property ) { $ fields .= "c." . $ property -> getColumn ( ) . ", " ; } $ fields = substr_replace ( $ fields , "" , - 2 ) ; if ( $ relation -> getCardinality ( ) == Relation :: $ manyToMany ) { $ query = "select " . $ fields . " from " . $ mapperRelation -> getTable ( ) . " c " ; $ query .= "inner join " . $ relation -> getTable ( ) . " nc on nc." . $ relation -> getForeignColumn ( ) . " = c.id " ; $ query .= "where nc." . $ relation -> getLocalColumn ( ) . " = :id" ; } if ( $ relation -> getCardinality ( ) == Relation :: $ oneToMany ) { $ query = "select " . $ fields . " from " . $ mapperRelation -> getTable ( ) . " c " ; $ query .= "where c." . $ relation -> getForeignColumn ( ) . " = :id" ; } return $ query ; }
Get the query for select the related entitys.
@param type $entity
@param type $relation Name of the relation.
Get the query for select the related entitys .