Jump to content

[RESOLU] Db::getInstance()->insert( sur tableau mutli-dimensionnelle


Recommended Posts

Boonjour A tous.

 

Dans le cadre d'un developpment de moduls j'ia beosin d'insérer dans le contenu d'un tableau multidimensionnels.

 

Aujourd'hui je passe en revue le tableau pas un foreach, puis insert, ce qui génère autant de requete que de ligne.

 

Je em demandais si il était possible de ne réaliser qu'un seul requête?

 

  foreach ($rss_links as $value)
  {
$url = $value['url'];
$title = $value['title'];
Db::getInstance()->insert('rsspersocontent', array(
'shop_id' => (int)$shop_id,
'cat_id' => (int)$cat_id,
'url' => pSQL($url),
'title' => pSQL($title),
));
  }

 

Merci à vous.

Edited by jd440 (see edit history)
Link to comment
Share on other sites

Salut,

 

Regarde la class Db te donne des infos:

/**
* Execute an INSERT query
*
* @param string $table Table name without prefix
* @param array $data Data to insert as associative array. If $data is a list of arrays, multiple insert will be done
* @param bool $null_values If we want to use NULL values instead of empty quotes
* @param bool $use_cache
* @param int $type Must be Db::INSERT or Db::INSERT_IGNORE or Db::REPLACE
* @param bool $add_prefix Add or not _DB_PREFIX_ before table name
* @return bool
*/

La méthode gère les INSERT multiple ;)

  • Like 1
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...