/** * 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 = ShlDbHelper::arrayToIntValList($ids); // read urls and their duplicates $query = 'select r2.id' . ' from `#__sh404sef_urls` as r1' . ' join `#__sh404sef_urls` as r2' . ' on r1.`oldurl` = r2.`oldurl`' . ' where r1.' . $this->_db->quoteName('id') . ' in (' . $whereIds . ')'; try { // perform query $this->_db->setQuery($query); $urlsIds = $this->_db->shlLoadResultArray(); // 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 ShlDbHelper::deleteIn('#__sh404sef_urls', 'id', $urlsIds); } catch (Exception $e) { ShlSystem_Log::error('sh404sef', '%s::%s::%d: %s', __CLASS__, __METHOD__, __LINE__, $e->getMessage()); $this->setError('Internal database error # ' . $e->getMessage()); } return true; }