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

Pimcore

Top Pimcore 5 Interview Questions And Answers

Top Pimcore 5 Interview Questions And Answers Part 1

Leave a Reply

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