Ejemplo n.º 1
0
 /**
  * Get the map of IDs to blog URLs
  *
  * @param   ADatabaseDriver $db The database connection
  *
  * @return  array  The map, or an empty array if this is not a multisite installation
  */
 protected function getMultisiteMap($db)
 {
     static $map = null;
     if (is_null($map)) {
         /** @var AngieModelWordpressConfiguration $config */
         $config = AModel::getAnInstance('Configuration', 'AngieModel', array(), $this->container);
         // Which site ID should I use?
         $site_id = $config->get('site_id_current_site', 1);
         // Get all of the blogs of this site
         $query = $db->getQuery(true)->select(array($db->qn('blog_id'), $db->qn('domain'), $db->qn('path')))->from($db->qn('#__blogs'))->where($db->qn('site_id') . ' = ' . $db->q($site_id));
         try {
             $map = $db->setQuery($query)->loadAssocList('blog_id');
         } catch (Exception $e) {
             $map = array();
         }
     }
     return $map;
 }
Ejemplo n.º 2
0
 /**
  * Perform a simple replacement on the current table
  *
  * @param ADatabaseDriver $db
  *
  * @return void
  */
 protected function performSimpleReplacement($db)
 {
     $tableName = $this->currentTable['table'];
     // Run all replacements
     foreach ($this->replacements as $from => $to) {
         $query = $db->getQuery(true)->update($db->qn($tableName));
         foreach ($this->currentTable['fields'] as $field) {
             $query->set($db->qn($field) . ' = REPLACE(' . $db->qn($field) . ', ' . $db->q($from) . ', ' . $db->q($to) . ')');
         }
         try {
             $db->setQuery($query)->execute();
         } catch (Exception $e) {
             // Do nothing if the replacement fails
         }
     }
 }