Jump to content

ajout d'une table et erreur de lecture


Recommended Posts

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...