THELIA Forum

Welcome to the THELIA support and discusssion forum

Announcement

Rejoignez la communauté sur le Discord Thelia : https://discord.gg/YgwpYEE3y3

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.

Last edited by Nog (07-05-2019 10:30:20)

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


OpenStudio Toulouse

Offline


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

Thanks a lot!