Get a Quote Right Now

Edit Template

Debugging: sql()

You can get the generated SQL from the query builder by calling getQuery() or getQueryAndParameters().

If you just want the query you can use getQuery()

            .getRepository(Customer)

            .createQueryBuilder("customer")

            .where("customer.id = :id", { id: 1 })

            // .getQuery()

//GIVES THIS RESULT

       // “SELECT `customer`.`id` AS `customer_id`, `customer`.`firstName` AS `customer_firstName`, `customer`.`lastName` AS `customer_lastName`, `customer`.`deletedAt` AS `customer_deletedAt` FROM `customer` `customer` WHERE ( `customer`.`id` = :id ) AND ( `customer`.`deletedAt` IS NULL )”

   //.getQueryAndParameters()

//GIVES THIS RESULT

            // [

            //     “SELECT `customer`.`id` AS `customer_id`, `customer`.`firstName` AS `customer_firstName`, `customer`.`lastName` AS `customer_lastName`, `customer`.`deletedAt` AS `customer_deletedAt` FROM `customer` `customer` WHERE ( `customer`.`id` = ? ) AND ( `customer`.`deletedAt` IS NULL )”,

            //     [

            //         1

            //     ]

            // ]

Share

Leave a Reply

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