ach34 Posted August 23, 2016 Share Posted August 23, 2016 Bonjour, Je veux récupérer une information dans un table que j'ai créé ps_COULEUR en fonction de la référence couleur. Dans product.tpl <p>{$product->getColor($product->reference)|escape:'html':'UTF-8'} </p> Dans product.php public function getColor($ref) { $result = Db::getInstance()->executeS('SELECT desc FROM '._DB_PREFIX_.'COULEUR WHERE ref = "'.$ref.'"'); return $result; } Mais j'ai l'erreur suivante : Warning: htmlspecialchars() expects parameter 1 to be string, array given in /share/MD0_DATA/Web/www/X009_analiadeco/dev/tools/smarty/sysplugins/smarty_internal_templatebase.php(157) : eval()'d code on line 317 Quelqu'un peut-il m'aider SVP. Merci de votre aide Link to comment Share on other sites More sharing options...
ach34 Posted August 23, 2016 Author Share Posted August 23, 2016 J'ai trouvé la solution public function getColor($ref) { return Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue(' SELECT `desc` FROM `'._DB_PREFIX_.'COULEUR` WHERE `ref` = \''.pSQL($ref).'\''); } Link to comment Share on other sites More sharing options...
Mediacom87 Posted August 23, 2016 Share Posted August 23, 2016 Bonjour, une bonne référence https://www.prestashop.com/blog/fr/les-bonnes-pratiques-de-la-classe-db-sur-prestashop-1-5/ Link to comment Share on other sites More sharing options...
ach34 Posted August 23, 2016 Author Share Posted August 23, 2016 Merci pour la référence 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