/** * Delete a list of urls from their ids, * passed as params * Also delete all duplicates * * @param array of integer $ids the list of url id to delete * @return boolean true if success */ public function deleteByIdsWithDuplicates($ids = array()) { if (empty($ids)) { return true; } // build a list of ids to read $whereIds = Sh404sefHelperDb::arrayToIntValList($ids); // read urls and their duplicates $query = 'select r2.id' . ' from `#__redirection` as r1' . ' join `#__redirection` as r2' . ' on r1.`oldurl` = r2.`oldurl`' . ' where r1.' . $this->_db->nameQuote('id') . ' in (' . $whereIds . ')'; // perform query $this->_db->setQuery($query); $urlsIds = $this->_db->loadResultArray(); // now delete urls from db and cache $rows = $this->_getNonSefUrls($urlsIds); if (!empty($rows)) { Sh404sefHelperCache::removeURLFromCache($rows); } // finally, we can simply delete from db by ids try { sh404sefHelperDb::deleteIn('#__redirection', 'id', $urlsIds); } catch (Sh404sefExceptionDefault $e) { $this->setError('Internal database error # ' . $e->getMessage()); } return true; }