THELIA Forum

Welcome to the THELIA support and discusssion forum

Offline


Hi! Where do i start for building a loop from a raw SQL query ? 
Can't find any example here http://doc.thelia.net/en/documentation/ … loops.html

Thanks.

Offline


Create a Thelia loop that implements the ArraySearchLoopInterface, and build an array with te results of your SQL request :

    public function buildArray()
    {
        $query = "SELECT ...";

        /** @var \PDO $connection */
        $connection = Propel::getConnection();

        /** @var PDODataFetcher $statement */
        $statement = $connection->query($query);

        $result = [];
        
        /** @var \PDOStatement $row */
        while ($statement && $row = $statement->fetch(\PDO::FETCH_ASSOC)) {
            $result[] = $row;
        }

        return $result;
    }

See http://doc.thelia.net/en/documentation/ … #example-1


CQFDev | Sites, boutiques, modules, développement et intégration pour Thelia 1 et 2

Offline


Roadster you're a machine cool !
I was trying to fit a square in a circle roll

Thanks a lot!