Amiral D. Posted February 26, 2013 Share Posted February 26, 2013 Hello everyone, I try to dev a solution for Prestashop, but i can't figure how to search by tag with the DbQuery object. I wrote this but it's false, can anyone help me ? $sql = new DbQuery(); $sql->select('*'); $sql->from('products', 'c'); $sql->innerJoin('product_tag', 'l', 'c.id_product = l.id_product'); $sql->innerJoin('tag', 'm', 'l.id_tag = m.id_tag'); $sql->where('m.name = apple'); $sql->orderBy('product_tag'); $res = Db::getInstance()->executeS($sql); print_r($res); -> Error 500 S.O.S. M. Link to comment Share on other sites More sharing options...
Alex Simonchik BelVG Posted February 26, 2013 Share Posted February 26, 2013 Hi, for debug sql-query use: $sql = new DbQuery(); $sql->select('*'); $sql->from('products', 'c'); $sql->innerJoin('product_tag', 'l', 'c.id_product = l.id_product'); $sql->innerJoin('tag', 'm', 'l.id_tag = m.id_tag'); $sql->where('m.name = apple'); $sql->orderBy('product_tag'); print_r((string)$sql); die; //or $sql->build() $res = Db::getInstance()->executeS($sql); print_r($res); Regards Link to comment Share on other sites More sharing options...
Amiral D. Posted February 26, 2013 Author Share Posted February 26, 2013 Thanks for your response, i've solved a part of it, just check what i've done : $sql = new DbQuery(); $sql->select('*'); $sql->from('product', 'p'); $sql->innerJoin('product_tag', 'l', 'p.id_product = l.id_product'); $sql->innerJoin('tag', 't', 'l.id_tag = t.id_tag'); $sql->where('t.name = "apple"'); $sql->orderBy('t.name'); $res = Db::getInstance()->executeS($sql); Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now