当前位置: 首页>>代码示例>>PHP>>正文


PHP db_set_active函数代码示例

本文整理汇总了PHP中db_set_active函数的典型用法代码示例。如果您正苦于以下问题:PHP db_set_active函数的具体用法?PHP db_set_active怎么用?PHP db_set_active使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了db_set_active函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getListeUser

    /**
     * (non-PHPdoc)
     * @see AbstractCallback::getListeUser()
     *
     * Fonction pour récupérer tous les utilisateurs ADEFIM
     *
     */
    public function getListeUser() {

        $users = array();

        db_set_active();

        $rids = array (
                8,  // CONSEILLER ADEFIM
                9,  // DIRECTEUR ADEFIM
                10, // GESTIONNAIRE ADEFIM
                12, // REFERENT ADEFIM
        );

        $query = db_select('users_roles', 'ur')
                    ->fields('ur', array('uid'))
                    ->condition('rid', $rids, 'IN');

        $results = $query->execute()->fetchAll();

        foreach ($results as $result) {
            $users[] = $result->uid;
        }

        $users = array_unique($users);

        return $users;

    }
开发者ID:HamzaBendidane,项目名称:prel,代码行数:35,代码来源:AllUserAdefim.php

示例2: getListeDestinataireMail

 /**
  * (non-PHPdoc)
  * @see AbstractCallback::getListeDestinataireMail()
  */
 public function getListeDestinataireMail() {
     
     $destinataires = array();
     
     db_set_active(@DB_EXTRANET);
     
     $query = db_select('user_responsable', 'ur');
     $query->join('user_entreprise', 'ue', 'ue.id_user_responsable = ur.id');
     $query->join('drupal_user', 'du', 'ue.id_drupal_user = du.id');
     $query->fields('ur');
     $query->condition('du.id_user_drupal' , $this->param->id_user, '=');
     $query->range(0,1);
     
     $result = $query->execute()->fetchAssoc();
     
     db_set_active();
     
     $destinataires[] = array(
         'email' => $result['email'],
         'name' => trim($result['prenom']) . ' ' . trim($result['nom'])
     );
     
     return $destinataires;
     
 }
开发者ID:HamzaBendidane,项目名称:prel,代码行数:29,代码来源:ResponsableUser.php

示例3: getListeUser

    /**
     * (non-PHPdoc)
     * @see AbstractCallback::getListeUser()
     *
     * Fonction pour récupérer tous les utilisateurs OPCAIM
     *
     */
    public function getListeUser() {

        $users = array();

        db_set_active();

        $rids = array (
                6, // ADMIN OPCAIM
                13 // SUPER ADMIN OPCAIM
        );

        $query = db_select('users_roles', 'ur')
                    ->fields('ur', array('uid'))
                    ->condition('rid', $rids, 'IN');

        $results = $query->execute()->fetchAll();

        foreach ($results as $result) {
            $users[] = $result->uid;
        }

        $users = array_unique($users);

        return $users;

    }
开发者ID:HamzaBendidane,项目名称:prel,代码行数:33,代码来源:AllUserOpcaim.php

示例4: getListeDestinataireMail

    /**
     * (non-PHPdoc)
     * @see AbstractCallback::getListeUser()
     * 
     * Fonction pour récupérer Les utilisateurs et leurs mails 
     * des ADEFIM rattachées rattachées aux entreprise
     * 
     */
    public function getListeDestinataireMail() {
        
        $destinataires = array();
        
        $id_entreprises = $this->param->id_entreprises;
        
        $id_adefims = array();
        
        foreach ($id_entreprises as $id_entreprise) {
            $id_adefims[] = shared_get_id_adefim_from_id_entreprise($id_entreprise);
        }
        
        db_set_active(@DB_SLAVE);
        
        $query = db_select('v_comptes_adefims', 'ca');
        $query->fields('ca');
        $query->condition('id_adefim', $id_adefims, 'IN');
        $result = $query->execute();
        $comptes_adefim = $result->fetchAll();
        
        db_set_active();
        
        foreach ($comptes_adefim as $compte_adefim) {

            $destinataires[] = array(
                'email' => $compte_adefim->email,
                'name' => trim($compte_adefim->prenom) . ' ' . trim($compte_adefim->nom)
            );
            
        }
        
        return $destinataires;
        
    }
开发者ID:HamzaBendidane,项目名称:prel,代码行数:42,代码来源:AllUserAdefimEtp.php

示例5: getListeDestinataireMail

 /**
  * (non-PHPdoc)
  * @see AbstractCallback::getListeDestinataireMail()
  */
 public function getListeDestinataireMail() {
     
     $destinataires = array();
     
     if (isset($this->param->id_user)) {
         db_set_active(@DB_EXTRANET);
         
         $query = db_select('drupal_user', 'du');
         $query->fields('du');
         $query->condition('du.id_user_drupal' , $this->param->id_user, '=');
         $query->range(0,1);
         
         $result = $query->execute()->fetchAssoc();
         
         db_set_active();
         
         if ($result) {
             $destinataires[] = array(
                     'email' => $result['mail'],
                     'name' => trim($result['first_name']) . ' ' 
                             . trim($result['last_name'])
             );
         }
         
     } else {
         // dans le cas d'un utilisateur supprimé
         $destinataires[] = array(
                 'email' => $this->param->email,
                 'name' => $this->param->name
         );
     }
     
     return $destinataires;
     
 }
开发者ID:HamzaBendidane,项目名称:prel,代码行数:39,代码来源:User.php

示例6: switch_to_db

 /**
 		@brief		Switch to the object's database if necessary.
 	**/
 public function switch_to_db()
 {
     // There is no extra database specified, which means we never change db.
     if (self::db() == '') {
         return;
     }
     db_set_active(self::db());
 }
开发者ID:Garth619,项目名称:wines-by-jennifer,代码行数:11,代码来源:db_aware_object.php

示例7: page_fast_cache

 function page_fast_cache()
 {
     if ($this->fast_cache === TRUE) {
         require_once './includes/database.inc';
         db_set_active();
     }
     return $this->fast_cache;
 }
开发者ID:kmewhort,项目名称:nomus,代码行数:8,代码来源:db.php

示例8: connect

  /**
   * {@inheritdoc}
   */
  protected function connect() {
    try {
      // This doesn't actually test the connection.
      db_set_active();
      // Now actually do a check.
      Database::getConnection();
      $this->pass('Drupal can CONNECT to the database ok.');
    }
    catch (\Exception $e) {
      // Attempt to create the database if it is not found.
      if ($e->getCode() == Connection::DATABASE_NOT_FOUND) {
        // Remove the database string from connection info.
        $connection_info = Database::getConnectionInfo();
        $database = $connection_info['default']['database'];
        unset($connection_info['default']['database']);

        // In order to change the Database::$databaseInfo array, need to remove
        // the active connection, then re-add it with the new info.
        Database::removeConnection('default');
        Database::addConnectionInfo('default', 'default', $connection_info['default']);

        try {
          // Now, attempt the connection again; if it's successful, attempt to
          // create the database.
          Database::getConnection()->createDatabase($database);
          Database::closeConnection();

          // Now, restore the database config.
          Database::removeConnection('default');
          $connection_info['default']['database'] = $database;
          Database::addConnectionInfo('default', 'default', $connection_info['default']);

          // Check the database connection.
          Database::getConnection();
          $this->pass('Drupal can CONNECT to the database ok.');
        }
        catch (DatabaseNotFoundException $e) {
          // Still no dice; probably a permission issue. Raise the error to the
          // installer.
          $this->fail(t('Database %database not found. The server reports the following message when attempting to create the database: %error.', array('%database' => $database, '%error' => $e->getMessage())));
          return FALSE;
        }
        catch (\PDOException $e) {
          // Still no dice; probably a permission issue. Raise the error to the
          // installer.
          $this->fail(t('Database %database not found. The server reports the following message when attempting to create the database: %error.', array('%database' => $database, '%error' => $e->getMessage())));
          return FALSE;
        }
      }
      else {
        // Database connection failed for some other reason than the database
        // not existing.
        $this->fail(t('Failed to connect to your database server. The server reports the following message: %error.<ul><li>Is the database server running?</li><li>Does the database exist, and have you entered the correct database name?</li><li>Have you entered the correct username and password?</li><li>Have you entered the correct database hostname?</li></ul>', array('%error' => $e->getMessage())));
        return FALSE;
      }
    }
    return TRUE;
  }
开发者ID:HamzaBendidane,项目名称:prel,代码行数:61,代码来源:Tasks.php

示例9: wyc_import_ratings

function wyc_import_ratings($member_number = '')
{
    db_set_active('wyc_import_database');
    //SELECT * FROM wyc_production.wyc_ratings r JOIN wyc_production.wycdatabase d ON r.member=d.WYCNumber ORDER BY r.date ASC
    /*$query = db_select('wyc_ratings', 'r');
    	$query->join('wycdatabase', 'd', 'r.member=d.WYCNumber');
    	$query
    		->fields('r')->fields('d')
    		->range(0, 100)
    		->orderBy('d.WYCNumber', 'DESC')
    		->orderBy('r.date', 'ASC');
    
    	if($member_number) {
    		$query->condition('r.member', $member_number); 
    	}*/
    // get all their ratings added that day
    // SELECT GROUP_CONCAT(r.rating  SEPARATOR '|') as d_ratings, r.*, d.* ".
    // "FROM wyc_production.wyc_ratings r ".
    // "LEFT JOIN wyc_production.wycdatabase d ON r.member=d.WYCNumber ".
    // "GROUP BY d.WYCNumber, r.examiner, r.date ".
    // "ORDER BY r.member
    #
    db_set_active();
    $query = db_select('wyc_ratings_import_cache', 'r');
    $query->fields('r')->condition('r.ratings_cache', '', '=');
    //->range(0, 100);
    $results = $query->execute();
    $drupal_users = $uids = array();
    while ($data = $results->fetchAssoc()) {
        print "\n\nFOUND RATINGS....\n" . json_encode($data);
        flush();
        list($rid, $rating_rating, $drupal_uid, $ratings_member, $rating_date, $rating_examiner, $ratings_comment) = array($data['id'], explode('|', $data['ratings']), $data['drupal_member'], $data['ratings_member'], $data['ratings_date'], $data['ratings_examiner'], $data['ratings_comment']);
        // cache ids
        if (empty($uids[$ratings_member])) {
            $uids[$ratings_member] = wyc_get_uid_by_wycnumber($ratings_member);
        }
        if (empty($uids[$rating_examiner])) {
            $uids[$rating_examiner] = wyc_get_uid_by_wycnumber($rating_examiner);
        }
        // cache users
        if (empty($ratings_member) || empty($drupal_users[$ratings_member]->uid)) {
            $id = $drupal_uid ? $drupal_uid : $uids[$ratings_member];
            $drupal_user = user_load($id);
            $drupal_users[$ratings_member] = $drupal_user;
        }
        if (empty($drupal_user->uid)) {
            wyc_log('wyc_ratings_missing_user', $data, WATCHDOG_ERROR);
        } else {
            wyc_log('wyc_ratings_adding_ratings', $users[$ratings_member]->uid, WATCHDOG_NOTICE);
            wyc_add_rating($rid, $drupal_user, $ratings_member, $rating_date, $rating_rating, $uids[$rating_examiner], $ratings_comment);
        }
    }
}
开发者ID:sodacrackers,项目名称:washyacht,代码行数:53,代码来源:wyc_drush_users.php

示例10: get_data1d

function get_data1d($lakeid, $variable)
{
    $sqlstatement = get_sql_query($lakeid, $variable);
    db_set_active('dbmaker');
    $result = db_query($sqlstatement);
    //Initialize arrays
    $idx = 0;
    $Dates = array();
    $Values = array();
    foreach ($result as $row) {
        $Dates[$idx] = $row->sampledate;
        $Values[$idx++] = $row->{$variable};
    }
    db_set_active('default');
    $GLOBALS['numsamps'] = $idx;
    $GLOBALS['Dates'] = $Dates;
    $GLOBALS['Values'] = $Values;
}
开发者ID:syncnj,项目名称:LTER-Buoys,代码行数:18,代码来源:d3_1d.module.php

示例11: getListeUser

 /**
  * (non-PHPdoc)
  * @see AbstractCallback::getListeUser()
  * 
  * Fonction pour récupérer l'utilisateur ayant créé la DGF
  * 
  */
 public function getListeUser() {
     
     $users = array();
     
     db_set_active(@DB_EXTRANET);
     
     $query = db_select('dgf', 'd')
     ->fields('d', array('id_user_creation'))
     ->condition('id', $this->param, '=');
     
     $results = $query->execute()->fetchAssoc();
     
     $users[] = $results['id_user_creation'];
     
     db_set_active();
     
     return $users;
     
 }
开发者ID:HamzaBendidane,项目名称:prel,代码行数:26,代码来源:OwnerDGF.php

示例12: getListeUser

 /**
  * (non-PHPdoc)
  * @see AbstractCallback::getListeUser()
  * 
  * Fonction pour récupérer Le référent (et Directeur si différent) 
  * de l’ADEFIM rattachée 
  * 
  */
 public function getListeUser() {
     
     $users = array();
     
     $id_entreprises = $this->param->id_entreprises;
     
     db_set_active(@DB_EXTRANET);
     
     $query = db_select('user_entreprise', 'ue');
     $query->join('lien_user_entreprise_ref_esclave_entreprise', 'luee', 'luee.id_user_entreprise = ue.id');
     $query->join('drupal_user', 'du', 'ue.id_drupal_user = du.id');
     $query->fields('du', array('id_user_drupal'));
     $query->condition('luee.est_actif' , 1, '=');
     //filtre par entreprise
     $query->condition('luee.id_ref_esclave_entreprise', $id_entreprises, 'IN');
     
     $results = $query->execute()->fetchAll();
     
     db_set_active();
     
     foreach ($results as $result) {
         
         //chercher si l'utilisateur existe dans drupal
         $user = user_load($result->id_user_drupal);
         
         if ($user != false) {
             
             // Vérifier si l'utilisateur est ADMIN ENTREPISE (role 5)
             // @todo RESPONSABLE ENTREPISE
             if (user_has_role(5,$user)) {
                 $users[] = $user->uid;
             }
         }
     }
     
     // Supprimer les doublons si plusieurs entreprises
     $users = array_unique($users);
     
     return $users;
     
 }
开发者ID:HamzaBendidane,项目名称:prel,代码行数:49,代码来源:AdminResponsableEtp.php

示例13: getListeUser

 /**
  * (non-PHPdoc)
  * @see AbstractCallback::getListeUser()
  * 
  * Fonction pour récupérer Le référent (et Directeur si différent) 
  * de l’ADEFIM rattachée à partir de la liste d'ID Entreprise
  * 
  */
 public function getListeUser() {
     
     $users = array();
     
     $ids_entreprise = $this->param->id_entreprises;
     
     db_set_active(@DB_SLAVE);
     
     $query = db_select('comptes_adefims', 'ca');
     $query->join('fonctions_adefims', 'fa', 'ca.id_fonction_adefim = fa.id');
     $query->join('adefims', 'a', 'ca.id_adefim = a.id');
     $query->join('v_adefims_entreprise', 'lae', 'lae.id_adefim = a.id');
     $query->join('entreprises', 'e', 'lae.id_entreprise = e.id');
     $query->fields('ca', array('id','nom_utilisateur'));
     $query->condition('a.est_actif' , 1, '=');
     $query->condition('ca.est_actif' , 1, '=');
     //filtre par entreprise
     $query->condition('e.id', $ids_entreprise, 'IN');
     //filtre par fonction Directeur et Référent
     $query->condition('fa.id' , array('I.1','I.3'), 'IN');
     
     $results = $query->execute()->fetchAll();
     
     db_set_active();
     
     //Récupération des uid des users Adefim depuis drupal
     foreach ($results as $user_adefim) {
         $user = user_load_by_name(rtrim($user_adefim->nom_utilisateur));
         if ($user != false) {
             $users[] = $user->uid;
         }
     }
     
     // Supprimer les doublons si plusieurs entreprises
     $users = array_unique($users);
     
     return $users;
     
 }
开发者ID:HamzaBendidane,项目名称:prel,代码行数:47,代码来源:ReferentDirecteurAdefim.php

示例14: getSyslog

function getSyslog($limit = FALSE, $start = FALSE)
{
    global $priorities;
    $sql = 'SELECT * FROM (' . '  SELECT' . '    id,' . '    DATE_PART(\'epoch\', devicereportedtime) AS time,' . '    priority AS priority_id,' . '    message,' . '    syslogtag AS service' . '    FROM systemevents' . '    WHERE facility = ?';
    $params = array(SYSLOG_MAIL);
    if ($start) {
        $sql .= ' AND id > ?';
        $params[] = $start;
    }
    $sql .= ' ORDER BY id DESC';
    if ($limit) {
        $sql .= ' LIMIT ?';
        $params[] = $limit;
    }
    $sql .= ') AS LOG' . '  ORDER BY id';
    db_set_active('logs');
    $rows = db_getrows($sql, $params);
    db_set_active('default');
    if (!$rows) {
        return FALSE;
    }
    $i = 0;
    foreach ($rows as $row) {
        $pid = null;
        $service = str_replace(':', '', $row['service']);
        if (preg_match('/^(.*)\\[(.*)\\]$/', $service, $matches)) {
            $service = $matches[1];
            $pid = $matches[2];
        }
        $rows[$i]['pid'] = $pid;
        $rows[$i]['service'] = $service;
        $message = htmlspecialchars($row['message']);
        $rows[$i]['message'] = $message;
        $i++;
    }
    return $rows;
}
开发者ID:rubixconsulting,项目名称:postfixweb,代码行数:37,代码来源:syslog.inc.php

示例15: connect

 /**
  * Check if we can connect to the database.
  */
 protected function connect()
 {
     try {
         // This doesn't actually test the connection.
         db_set_active();
         // Now actually do a check.
         Database::getConnection();
         $this->pass('Drupal can CONNECT to the database ok.');
     } catch (\Exception $e) {
         $this->fail(t('Failed to connect to your database server. The server reports the following message: %error.<ul><li>Is the database server running?</li><li>Does the database exist, and have you entered the correct database name?</li><li>Have you entered the correct username and password?</li><li>Have you entered the correct database hostname?</li></ul>', array('%error' => $e->getMessage())));
         return FALSE;
     }
     return TRUE;
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:17,代码来源:Tasks.php


注:本文中的db_set_active函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。