jd440 Posted August 8, 2013 Share Posted August 8, 2013 (edited) 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 August 8, 2013 by jd440 (see edit history) Link to comment Share on other sites More sharing options...
Matt75 Posted August 8, 2013 Share Posted August 8, 2013 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 1 Link to comment Share on other sites More sharing options...
jd440 Posted August 8, 2013 Author Share Posted August 8, 2013 Merci! 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