Home » PHP » Pimcore » Raw sql query using Pimcore\Db class in PIMCORE 5

Raw sql query using Pimcore\Db class in PIMCORE 5

Pimcore

Please use the below steps to fetch the data from Pimcore Database.

1. To connect the Pimcore DB
2. This query fetch the id only.
3. This query fetch all records.
4. This query fetch the latest single record.
5. This will load the data. If you will not use this and will print the $sql it will return the structure of all possible query.

 1. $db = \Pimcore\Db::get();
 2. $sql = $db->fetchCol("SELECT * FROM `object_1`");
 3. $sql = $db->fetchAll("SELECT * FROM `object_1`");
 4. $sql = $db->fetchRow("SELECT * FROM `object_1`");
 5. $sql ->load();

Check Also

Top Twig Template Interview And Answer Part 1

1. How can we the path with param variables in twig template? {{ path('abc',{'test':'1'}) }} …

Leave a Reply

Your email address will not be published. Required fields are marked *