lagrandeours Posted January 13, 2012 Share Posted January 13, 2012 Bonjour, je souhaite comprendre le fonctionnement du bouton 'SAVE' dans administrator/index.php?tab=AdminCatalog. le principal code est bien sur l'ajout du formulaire dans la base de donne : $target = Tools::getValue('id'); $name = Tools::getValue('name'); Db::getInstance()->autoExecute('target_table', array( 'id_target' => (int)$target, 'name' => pSQL($name), ), 'INSERT'); cependant j'arrive pas a trouver cet insert dans les fichier de prestashop. merci pour votre aide/ explication. hh Link to comment Share on other sites More sharing options...
coeos.pro Posted January 13, 2012 Share Posted January 13, 2012 Bonjour, il me semble que c'est dans le fichier classes/Db.php grosso modo : Db::getInstance()->autoExecute(nom_de_la_table,les valeurs sous formes d'array, 'INSERT' ou 'UPDATE'); Link to comment Share on other sites More sharing options...
lagrandeours Posted January 13, 2012 Author Share Posted January 13, 2012 merci coeos, mais j arrive pas a trouver un AutoExecute(_DB_PREFIX_.'product' ni un insert 'product'... je recherche avec grepwin... mais sans succes Link to comment Share on other sites More sharing options...
lagrandeours Posted January 13, 2012 Author Share Posted January 13, 2012 ... Link to comment Share on other sites More sharing options...
coeos.pro Posted January 17, 2012 Share Posted January 17, 2012 c'est dans le fichier classes/Db.php /** * Filter SQL query within a blacklist * * @param string $table Table where insert/update data * @param string $values Data to insert/update * @param string $type INSERT or UPDATE * @param string $where WHERE clause, only for UPDATE (optional) * @param string $limit LIMIT clause (optional) * @return mixed|boolean SQL query result */ public function autoExecute($table, $values, $type, $where = false, $limit = false, $use_cache = 1) { if (!sizeof($values)) return true; if (strtoupper($type) == 'INSERT') { $query = 'INSERT INTO `'.$table.'` ('; foreach ($values AS $key => $value) $query .= '`'.$key.'`,'; $query = rtrim($query, ',').') VALUES ('; foreach ($values AS $key => $value) $query .= '\''.$value.'\','; $query = rtrim($query, ',').')'; if ($limit) $query .= ' LIMIT '.(int)($limit); return $this->q($query, $use_cache); } elseif (strtoupper($type) == 'UPDATE') { $query = 'UPDATE `'.$table.'` SET '; foreach ($values AS $key => $value) $query .= '`'.$key.'` = \''.$value.'\','; $query = rtrim($query, ','); if ($where) $query .= ' WHERE '.$where; if ($limit) $query .= ' LIMIT '.(int)($limit); return $this->q($query, $use_cache); } return false; } 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