Search the Community
Showing results for tags 'dbquery'.
-
Hello! I'm trying to create a query using DbQuery() and it seems that this class automatically sets the table prefix 'ps_' or whichever you have so you don't have to set it. For example: $query = new DbQuery(); $query->select(' whatever '); $query->from('product', 'p'); $query->innerJoin('product_lang', 'pl', 'pl.id_product = p.id_product'); $query->innerJoin('category_product', 'cp', 'cp.id_product = p.id_product'); As you can see, you don't need to write $query->from('ps_product', 'p'); It knows already the prefix to the tables. My problem is that I am trying to make a Left Join to a table I created with a different prefix, or not using the preset prefix at all. Having done that maybe a mistake, I don't know, but usually, the tables I create in my Prestashop database, have a different prefix to indicate to myself those are my tables. I know that there is something like '$addprefix = false' for DbQuery() but I can't find the documentation about it and where to set that false, and how to write the code about the table then. I am sure this has an easy solution. I have tried something like this: $query->leftJoin('frik_location', 'fl', 'fl.id_product = p.id_product AND fl.id_product_attribute = IFNULL(pa.id_product_attribute, 0)' , false); With that false at the end, but it does not work. So my table is called fik_location instead of ps_location (if i were to use the default prefix), anyone could help me with this? Thanks a lot in advance!
-
Bonsoir à tous, Je développe actuellement une solution sur Prestashop, mais je coince sur le l'objet DbQuery. Je cherche à effectuer une recherche de produits en les cherchant dans les tags, j'ai donc écris : $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); Il en ressort une erreur 500, je ne comprends pas où se situe l'erreur, même si je dois avouer que je n'ai jamais été un grand fan des ORM. Quelqu'un peut il m'éclairer svp ? Merci d'avance, M.
- 9 replies
-
- produits
- frontoffice
-
(and 3 more)
Tagged with: