コード例 #1
0
ファイル: wordpressreplacedata.php プロジェクト: akeeba/angie
 /**
  * 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;
 }
コード例 #2
0
ファイル: pdo.php プロジェクト: akeeba/angie
 /**
  * Sets the SQL statement string for later execution.
  *
  * @param   mixed    $query          The SQL statement to set either as a JDatabaseQuery object or a string.
  * @param   integer  $offset         The affected row offset to set.
  * @param   integer  $limit          The maximum affected rows to set.
  * @param   array    $driverOptions  The optional PDO driver options
  *
  * @return  Pdo  This object to support method chaining.
  *
  * @since   1.0
  */
 public function setQuery($query, $offset = null, $limit = null, $driverOptions = array())
 {
     $this->connect();
     $this->freeResult();
     if (is_string($query)) {
         // Allows taking advantage of bound variables in a direct query:
         $query = $this->getQuery(true)->setQuery($query);
     }
     if ($query instanceof ADatabaseQueryLimitable && !is_null($offset) && !is_null($limit)) {
         $query->setLimit($limit, $offset);
     }
     $sql = $this->replacePrefix((string) $query);
     $this->prepared = $this->connection->prepare($sql, $driverOptions);
     // Store reference to the DatabaseQuery instance:
     parent::setQuery($query, $offset, $limit);
     return $this;
 }
コード例 #3
0
ファイル: mauticreplacedata.php プロジェクト: akeeba/angie
 /**
  * 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
         }
     }
 }