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;
    }