Asked 2 years ago
9 Aug 2021
Views 969
steave ray

steave ray posted

how to print sql query in prestashop



        $sql = new DbQuery();
        $sql->select('c.`passwd`');
        $sql->from('customer', 'c');
        $sql->where('c.`email` = \'' . pSQL($email) . '\'');

How can I view the SQL query on Smarty , in other word , how to print sql query in prestashop ?
debugger

debugger
answered Aug 9 '21 00:00

__toString()
Generate and get the query.


 $sql = new DbQuery();
 $sql->select('c.`passwd`');
 $sql->from('customer', 'c');
 $sql->where('c.`email` = \'' . pSQL($email) . '\'')
echo $sql->__toString();


it will print like this for example :

SELECT c.`passwd` FROM `rtn_customer` c WHERE (c.`email` = 'infores@gmail.com')



__toString() is used to convert sql object query to string .
Post Answer