Jump to content

Problème de simplification d'une fonction update


Recommended Posts

Bonjour je cherche a simplifier une fonction que voici :

public function hookActionProductUpdate($params)
	{
		// get all languages
		// for each of them, store the custom field!

		$id_product = (int)Tools::getValue('id_product');
		$languages = Language::getLanguages(true);
		foreach ($languages as $lang) {
			if(!Db::getInstance()->update('product_lang', array('custom_field'=> pSQL(Tools::getValue('custom_field_'.$lang['id_lang']))) ,'id_lang = ' . $lang['id_lang'] .' AND id_product = ' .$id_product ))
				$this->context->controller->_errors[] = Tools::displayError('Error: ').mysql_error();
		}

	}

j'ai effectué des changements : mon champs custom_field se trouve maintenant dans la table product et je ne souhaite plus  de variable $lang

 

j'ai donc essayé ceci mais sa na pas l'air de fonctionner :

public function hookActionProductUpdate($params)
	{
		
		$id_product = (int)Tools::getValue('id_product');
	
		Db::getInstance()->update('product', array('custom_field'=> pSQL(Tools::getValue('custom_field' .' AND `id_product` = ' .$id_product)
				$this->context->controller->_errors[] = Tools::displayError('Error: ').mysql_error();

	}

quelqu’un peut il m'éclairer ? Merci d'avance.

Edited by almeidaz (see edit history)
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...