src/ActiveDoctrine/Entity/Entity.php
/**
     * Select all entities matching an SQL query, and return the
     * results as a collection.
     *
     * @param Connection $connection   A connection instance
     * @param string     $sql          The SQL query
     * @param array      $parameters   Any bound parameters required for the query
     * @param array      $field_mapping An array of result columns => entity fields
     *
     * @return EntityCollection A collection containing the selected entities
     */
Select all entities matching an SQL query, and return the
results as a collection.

@param Connection $connection   A connection instance
@param string     $sql          The SQL query
@param array      $parameters   Any bound parameters required for the query
@param array      $field_mapping An array of result columns => entity fields

@return EntityCollection A collection containing the selected entities
Select all entities matching an SQL query and return the results as a collection . @param Connection $connection A connection instance @param string $sql The SQL query @param array $parameters Any bound parameters required for the query @param array $field_mapping An array of result columns = > entity fields @return EntityCollection A collection containing the selected entities
public static function selectSQL(Connection $connection, $sql, array $parameters = [], array $field_mapping = [])
    {
        $stmt = $connection->prepare($sql);
        $stmt->execute($parameters);
        $results = array();
        while ($result = $stmt->fetch()) {
            foreach ($field_mapping as $result_column => $entity_field) {
                if (!isset($result[$result_column])) {
                    continue;
                }
                $result[$entity_field] = $result[$result_column];
                unset($result[$result_column]);
            }
            foreach (static::$types as $column => $type) {
                if (isset($result[$column])) {
                    $result[$column] = $connection->convertToPHPValue($result[$column], $type);
                }
            }
            $obj = new static($connection, $result);
            $obj->setStored();
            $results[] = $obj;
        }
        $collection = static::newCollection();
        $collection->setEntities($results);
        return $collection;
    }
public static function selectSQL ( Connection $ connection , $ sql , array $ parameters = [ ] , array $ field_mapping = [ ] ) { $ stmt = $ connection -> prepare ( $ sql ) ; $ stmt -> execute ( $ parameters ) ; $ results = array ( ) ; while ( $ result = $ stmt -> fetch ( ) ) { foreach ( $ field_mapping as $ result_column => $ entity_field ) { if ( ! isset ( $ result [ $ result_column ] ) ) { continue ; } $ result [ $ entity_field ] = $ result [ $ result_column ] ; unset ( $ result [ $ result_column ] ) ; } foreach ( static :: $ types as $ column => $ type ) { if ( isset ( $ result [ $ column ] ) ) { $ result [ $ column ] = $ connection -> convertToPHPValue ( $ result [ $ column ] , $ type ) ; } } $ obj = new static ( $ connection , $ result ) ; $ obj -> setStored ( ) ; $ results [ ] = $ obj ; } $ collection = static :: newCollection ( ) ; $ collection -> setEntities ( $ results ) ; return $ collection ; }
Select all entities matching an SQL query, and return the
 results as a collection.
Select all entities matching an SQL query and return the results as a collection .