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


PHP XDB::fetchAllAssoc方法代码示例

本文整理汇总了PHP中XDB::fetchAllAssoc方法的典型用法代码示例。如果您正苦于以下问题:PHP XDB::fetchAllAssoc方法的具体用法?PHP XDB::fetchAllAssoc怎么用?PHP XDB::fetchAllAssoc使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在XDB的用法示例。


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

示例1: fetchJobs

 private function fetchJobs(ProfilePage $page)
 {
     // Build the jobs tree
     $jobs = XDB::fetchAllAssoc('SELECT  j.id, j.jobid, je.name,
                                          j.description, j.email AS w_email,
                                          j.email_pub AS w_email_pub,
                                          j.url AS w_url, j.pub, j.entry_year AS w_entry_year
                                    FROM  profile_job      AS j
                               LEFT JOIN  profile_job_enum AS je ON (j.jobid = je.id)
                                   WHERE  j.pid = {?}
                                ORDER BY  j.id', $page->pid());
     if (empty($jobs)) {
         return array($this->emptyJob());
     }
     $compagnies = array();
     $backtrack = array();
     foreach ($jobs as $key => $job) {
         $compagnies[] = $job['jobid'];
         $backtrack[$job['id']] = $key;
     }
     $it = Address::iterate(array($page->pid()), array(Address::LINK_JOB), array(), Visibility::get(Visibility::VIEW_ADMIN));
     while ($address = $it->next()) {
         $jobs[$address->id]['w_address'] = $address->toFormArray();
     }
     $it = Phone::iterate(array($page->pid()), array(Phone::LINK_JOB), array(), Visibility::get(Visibility::VIEW_ADMIN));
     while ($phone = $it->next()) {
         $jobs[$phone->link_id]['w_phone'][$phone->id] = $phone->toFormArray();
     }
     $res = XDB::iterator("SELECT  e.jtid, e.full_name, j.jid\n                                FROM  profile_job_term_enum AS e\n                          INNER JOIN  profile_job_term AS j USING(jtid)\n                               WHERE  pid = {?}\n                            ORDER BY  j.jid", $page->pid());
     while ($term = $res->next()) {
         // $jid is the ID of the job among this user's jobs
         $jid = $term['jid'];
         if (!isset($backtrack[$jid])) {
             continue;
         }
         $job =& $jobs[$backtrack[$jid]];
         if (!isset($job['terms'])) {
             $job['terms'] = array();
         }
         $job['terms'][] = $term;
     }
     $phone = new Phone();
     $address = new Address();
     foreach ($jobs as $id => &$job) {
         if (!isset($job['w_phone'])) {
             $job['w_phone'] = array(0 => $phone->toFormArray());
         }
         if (!isset($job['w_address'])) {
             $job['w_address'] = $address->toFormArray();
         }
         $job['w_email_new'] = '';
         if (!isset($job['w_email_pub'])) {
             $job['w_email_pub'] = 'private';
         }
     }
     return $jobs;
 }
开发者ID:Ekleog,项目名称:platal,代码行数:57,代码来源:jobs.inc.php

示例2: __construct

 /** The constructor, creates a new entry in the sessions table
  *
  * @param $uid the id of the logged user
  * @param $suid the id of the administrator who has just su'd to the user
  * @return VOID
  */
 public function __construct($uid, $suid = 0)
 {
     // write the session entry
     $this->uid = $uid;
     $this->session = $this->writeSession($uid, $suid);
     // retrieve available actions
     $this->actions = XDB::fetchAllAssoc('text', 'SELECT  id, text
                                                    FROM  log_actions');
 }
开发者ID:Ekleog,项目名称:platal,代码行数:15,代码来源:platallogger.php

示例3: __construct

 public function __construct(User $user, array $uids, $group, $dim)
 {
     parent::__construct($user, false, 'bulkaccounts');
     $this->group = $group;
     $this->dim = $dim;
     $this->users = XDB::fetchAllAssoc('SELECT  uid, hruid, email
                                          FROM  accounts
                                         WHERE  uid IN {?}', $uids);
 }
开发者ID:Ekleog,项目名称:platal,代码行数:9,代码来源:bulkaccounts.inc.php

示例4: __construct

 public function __construct(User $user, $hruid, $email, $group, $dim)
 {
     parent::__construct($user, false, 'account');
     $this->hruid = $hruid;
     $this->email = $email;
     $this->group = $group;
     $this->dim = $dim;
     $this->uid = XDB::fetchOneCell('SELECT  uid
                                       FROM  accounts
                                      WHERE  hruid = {?}', $hruid);
     $this->groups = XDB::fetchAllAssoc('SELECT  g.nom, g.diminutif
                                           FROM  groups AS g
                                     INNER JOIN  group_members AS m ON (g.id = m.asso_id)
                                          WHERE  m.uid = {?}
                                       ORDER BY  g.nom', $this->uid);
 }
开发者ID:Ekleog,项目名称:platal,代码行数:16,代码来源:account.inc.php

示例5: value

 public function value(ProfilePage $page, $field, $value, &$success)
 {
     $success = true;
     if (is_null($value) || !S::user()->isMyProfile($profile) && $page->values['medals_pub'] == 'private' && !S::user()->checkPerms(User::PERM_DIRECTORY_PRIVATE)) {
         // Fetch already attributed medals
         $value = XDB::fetchAllAssoc("SELECT  m.mid AS id, m.gid AS grade, 1 AS valid, FIND_IN_SET('has_levels', e.flags) AS has_levels, m.level\n                                           FROM  profile_medals     AS m\n                                     INNER JOIN  profile_medal_enum AS e ON (m.mid = e.id)\n                                          WHERE  m.pid = {?}", $page->pid());
         // Fetch not yet validated medals
         $medals = ProfileValidate::get_typed_requests($page->pid(), 'medal');
         foreach ($medals as &$medal) {
             $value[] = array('id' => $medal->mid, 'grade' => $medal->gid, 'level' => $medal->level, 'has_levels' => $medal->has_levels, 'valid' => '0');
         }
     } elseif (!is_array($value)) {
         $value = array();
     }
     usort($value, 'self::compareMedals');
     return $value;
 }
开发者ID:Ekleog,项目名称:platal,代码行数:17,代码来源:decos.inc.php

示例6: handler_marketing

 function handler_marketing($page)
 {
     $page->changeTpl('marketing/index.tpl');
     $page->setTitle('Marketing');
     $alive = array('all' => new ProfileFilter(new PFC_Not(new UFC_Dead())), 'women' => new ProfileFilter(new PFC_And(new UFC_Sex(User::GENDER_FEMALE), new PFC_Not(new UFC_Dead()))), 'x' => new ProfileFilter(new PFC_And(new PFC_Not(new UFC_Dead()), new UFC_AccountType('x'))), '72' => new ProfileFilter(new PFC_And(new UFC_Promo('>=', UserFilter::GRADE_ING, 1972), new PFC_Not(new UFC_Dead()))), 'master' => new ProfileFilter(new PFC_And(new PFC_Not(new UFC_Dead()), new UFC_AccountType('master'))), 'phd' => new ProfileFilter(new PFC_And(new PFC_Not(new UFC_Dead()), new UFC_AccountType('phd'))));
     $registered = array('all' => new ProfileFilter(new PFC_And(new UFC_Registered(true), new PFC_Not(new UFC_Dead()))), 'women' => new ProfileFilter(new PFC_And(new UFC_Registered(true), new UFC_Sex(User::GENDER_FEMALE), new PFC_Not(new UFC_Dead()))), 'x' => new ProfileFilter(new PFC_And(new UFC_Registered(true), new PFC_Not(new UFC_Dead()), new UFC_AccountType('x'))), '72' => new ProfileFilter(new PFC_And(new UFC_Registered(true), new UFC_Promo('>=', UserFilter::GRADE_ING, 1972), new PFC_Not(new UFC_Dead()))), 'master' => new ProfileFilter(new PFC_And(new UFC_Registered(true), new PFC_Not(new UFC_Dead()), new UFC_AccountType('master'))), 'phd' => new ProfileFilter(new PFC_And(new UFC_Registered(true), new PFC_Not(new UFC_Dead()), new UFC_AccountType('phd'))));
     $statistics = array('all' => array('description' => "Étudiants et anciens de l'X"), 'women' => array('description' => "Étudiantes et anciennes de l'X"), 'x' => array('description' => 'X'), '72' => array('description' => 'X vivants depuis la promo 1972'), 'master' => array('description' => "Masters de l'X"), 'phd' => array('description' => "Docteurs de l'X"));
     foreach ($statistics as $key => &$data) {
         $data['alive'] = $alive[$key]->getTotalCount();
         $data['registered'] = $registered[$key]->getTotalCount();
         $data['rate'] = round($data['registered'] / $data['alive'] * 100, 2);
     }
     $registeredWeek = new ProfileFilter(new PFC_And(new UFC_Registered(true, '>=', strtotime('1 week ago')), new PFC_Not(new UFC_Dead())));
     $registrationPending = XDB::fetchOneCell('SELECT  COUNT(*)
                                                 FROM  register_pending');
     $registrations = array('week' => $registeredWeek->getTotalCount(), 'pending' => $registrationPending);
     $ok = XDB::fetchOneCell('SELECT  COUNT(*)
                                FROM  register_mstats
                               WHERE  success != \'0000-00-00\'');
     $okWeek = XDB::fetchOneCell('SELECT  COUNT(*)
                                    FROM  register_mstats
                                   WHERE  success >= {?}', strtotime('1 week ago'));
     $res = XDB::fetchAllAssoc('SELECT  type, COUNT(*) as count
                                  FROM  register_marketing
                              GROUP BY  type');
     $no = array();
     foreach ($res as $value) {
         $no[$value['type']] = $value['count'];
     }
     $no['week'] = XDB::fetchOneCell('SELECT  COUNT(*)
                                        FROM  register_marketing
                                       WHERE  last >= {?}', strtotime('1 week ago'));
     $marketings = array('ok' => $ok, 'okWeek' => $okWeek, 'noPerso' => isset($no['user']) ? $no['user'] : 0, 'noXorg' => isset($no['staff']) ? $no['staff'] : 0, 'noAX' => isset($no['ax']) ? $no['ax'] : 0, 'noWeek' => $no['week']);
     $page->assign('statistics', $statistics);
     $page->assign('registrations', $registrations);
     $page->assign('marketings', $marketings);
 }
开发者ID:Ekleog,项目名称:platal,代码行数:37,代码来源:marketing.php

示例7: _getActions

 private function _getActions()
 {
     $actions = XDB::fetchAllAssoc('id', 'SELECT  id, description
                                            FROM  log_actions');
     $actions[0] = '----';
     ksort($actions);
     return $actions;
 }
开发者ID:Ekleog,项目名称:platal,代码行数:8,代码来源:admin.php

示例8: ON

 *  This program is distributed in the hope that it will be useful,        *
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
 *  GNU General Public License for more details.                           *
 *                                                                         *
 *  You should have received a copy of the GNU General Public License      *
 *  along with this program; if not, write to the Free Software            *
 *  Foundation, Inc.,                                                      *
 *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
 ***************************************************************************/
require_once 'connect.db.inc.php';
require_once 'plmailer.php';
$limit = 60;
$users = XDB::fetchAllAssoc('SELECT  a.uid, a.hruid, r.hash, r.group_name, r.sender_name, r.email
                               FROM  register_pending_xnet AS r
                         INNER JOIN  accounts              AS a ON (r.uid = a.uid)
                              WHERE  a.state = \'disabled\'
                           ORDER BY  r.date, a.uid');
$mailer = new PlMailer('xnet/account.mail.tpl');
$mailer->addCc('validation+xnet_account@polytechnique.org');
$i = 0;
foreach ($users as $user) {
    $mailer->setTo($user['email']);
    $mailer->assign('hash', $user['hash']);
    $mailer->assign('email', $user['email']);
    $mailer->assign('group', $user['group_name']);
    $mailer->assign('sender_name', $user['sender_name']);
    $mailer->assign('again', false);
    $mailer->assign('baseurl', Platal::globals()->baseurl);
    $mailer->send();
    XDB::execute('UPDATE  accounts
开发者ID:Ekleog,项目名称:platal,代码行数:31,代码来源:cron_xnet_accounts.php

示例9: foreach

        echo "Nouvelles adresses en panne detectees :\n";
        foreach ($res as $assoc) {
            echo '* ' . $assoc['redirect'] . ' pour ' . $assoc['hruid'] . "\n";
        }
        echo "\n\n";
        Xdb::execute("UPDATE  email_redirect_account\n                         SET  flags = 'broken'\n                       WHERE  broken_level = 3");
    }
    Xdb::execute('UPDATE  email_redirect_account
                     SET  broken_level = {?}
                   WHERE  broken_level > {?}', $panne_level, $panne_level);
}
/*
 * Retrieve the users with no active redirection, but still one working
 * inactive redirection.
 */
if ($opt_verbose) {
    $res = XDB::fetchAllAssoc("SELECT  a.hruid, r2.redirect\n                                 FROM  accounts               AS a\n                            LEFT JOIN  email_redirect_account AS r1 ON (a.uid = r1.uid AND r1.flags = 'active')\n                           INNER JOIN  email_redirect_account AS r2 ON (a.uid = r2.uid AND r2.flags = 'inactive'\n                                                                        AND r2.type != 'imap' AND r2.type != 'homonym')\n                                WHERE  r1.uid IS NULL\n                             GROUP BY  a.uid");
    if ($res) {
        echo "Camarades n'ayant plus d'adresses actives, mais ayant une adresse inactive :\n";
        foreach ($res as $user) {
            echo '* ' . $user['redirect'] . ' pour ' . $user['hruid'] . "\n";
        }
    }
    echo "\n";
}
/*
 * Updates imap settings for users with no active redirection. Their emails
 * must go to imap and bounce.
 */
XDB::execute("UPDATE  email_redirect_account AS r\n           LEFT JOIN  email_redirect_account AS a ON (r.uid = a.uid AND a.flags = 'active' AND a.type != 'imap')\n                 SET  r.action = 'imap_and_bounce'\n               WHERE  r.type = 'imap' AND a.redirect IS NULL");
// vim:set et sw=4 sts=4 sws=4 foldmethod=marker fenc=utf-8:
开发者ID:Ekleog,项目名称:platal,代码行数:31,代码来源:emails.check.php

示例10: value

 public function value(ProfilePage $page, $field, $value, &$success)
 {
     $success = true;
     if (is_null($value)) {
         $value = XDB::fetchAllAssoc('SELECT  type, text, pub
                                        FROM  profile_hobby
                                       WHERE  pid = {?}', $page->pid());
     }
     if (!is_array($value)) {
         return array();
     }
     foreach ($value as $i => &$hobby) {
         $hobby['text'] = trim($hobby['text']);
         if (!$hobby['text'] || !in_array($hobby['type'], self::$type)) {
             unset($value[$i]);
         } else {
             if (!isset($hobby['pub'])) {
                 $hobby['pub'] = 'private';
             }
             $s = true;
             $hobby['pub'] = $this->pub->value($page, 'pub', $hobby['pub'], $s);
             $success = $success && $s;
         }
     }
     return $value;
 }
开发者ID:Ekleog,项目名称:platal,代码行数:26,代码来源:general.inc.php

示例11: articleSearch

 public function articleSearch($search, $field, $user)
 {
     $search = XDB::formatWildcards(XDB::WILDCARD_CONTAINS, $search);
     if ($field == self::SEARCH_ALL) {
         $where = '(a.title ' . $search . ' OR a.body ' . $search . ' OR a.append ' . $search . ')';
     } else {
         $where = 'a.' . $field . $search;
     }
     $list = XDB::fetchAllAssoc('SELECT  i.short_name, a.aid, i.id, a.title
                                   FROM  newsletter_art    AS a
                             INNER JOIN  newsletter_issues AS i ON (a.id = i.id)
                                  WHERE  i.nlid = {?} AND i.state = \'sent\' AND ' . $where . '
                               GROUP BY  a.id, a.aid
                               ORDER BY  i.date DESC, a.aid', $this->id);
     $articles = array();
     foreach ($list as $item) {
         $issue = new NLIssue($item['id'], $this, false);
         if ($issue->checkUser($user)) {
             $articles[] = $item;
         }
     }
     return $articles;
 }
开发者ID:Ekleog,项目名称:platal,代码行数:23,代码来源:newsletter.inc.php

示例12: handler_jobterms

 /**
  * Page for url "profile/jobterms" (function also used for "referent/autocomplete" @see
  * handler_ref_autocomplete). Displays an "autocomplete" page (plain text with values
  * separated by "|" chars) for jobterms to add in profile.
  * @param $page the Platal page
  * @param $type set to 'mentor' to display the number of mentors for each term and order
  *  by descending number of mentors.
  *
  * @param Env::v('q') the text that has been typed and to complete automatically
  */
 function handler_jobterms($page, $type = 'nomentor')
 {
     pl_content_headers("text/plain");
     $q = Env::v('term') . '%';
     $tokens = JobTerms::tokenize($q);
     if (count($tokens) == 0) {
         exit;
     }
     sort($tokens);
     $q_normalized = implode(' ', $tokens);
     // Try to look in cached results.
     $cached = false;
     $cache = XDB::query('SELECT  result
                            FROM  search_autocomplete
                           WHERE  name = {?} AND query = {?} AND generated > NOW() - INTERVAL 1 DAY', $type, $q_normalized);
     if ($cache->numRows() > 0) {
         $cached = true;
         $data = explode("\n", $cache->fetchOneCell());
         $list = array();
         foreach ($data as $line) {
             if ($line != '') {
                 $aux = explode("\t", $line);
                 if ($type == 'mentor') {
                     $item = array('field' => $aux[0], 'nb' => $aux[1], 'id' => $aux[2]);
                     $item['value'] = SearchModule::format_autocomplete($item);
                 } else {
                     $item = array('value' => $aux[0], 'id' => $aux[1]);
                 }
                 array_push($list, $item);
             }
         }
     } else {
         $joins = JobTerms::token_join_query($tokens, 'e');
         if ($type == 'mentor') {
             $count = ', COUNT(DISTINCT pid) AS nb';
             $countjoin = ' INNER JOIN  profile_job_term_relation AS r ON(r.jtid_1 = e.jtid) INNER JOIN  profile_mentor_term AS m ON(r.jtid_2 = m.jtid)';
             $countorder = 'nb DESC, ';
         } else {
             $count = $countjoin = $countorder = '';
         }
         $list = XDB::fetchAllAssoc('SELECT  e.jtid AS id, e.full_name AS field' . $count . '
                                       FROM  profile_job_term_enum AS e ' . $joins . $countjoin . '
                                   GROUP BY  e.jtid
                                   ORDER BY  ' . $countorder . 'field
                                      LIMIT  ' . DirEnumeration::AUTOCOMPLETE_LIMIT);
         $to_cache = '';
         if ($type == 'mentor') {
             foreach ($list as &$item) {
                 $to_cache .= $item['field'] . "\t" . $item['nb'] . "\t" . $item['id'] . "\n";
                 $item['value'] = SearchModule::format_autocomplete($item);
             }
         } else {
             foreach ($list as &$item) {
                 $to_cache .= $item['field'] . "\t" . $item['id'] . "\n";
                 $item['value'] = $item['field'];
             }
         }
     }
     if (count($list) == DirEnumeration::AUTOCOMPLETE_LIMIT && $type == 'nomentor') {
         $list[] = array('value' => '… parcourir les résultats dans un arbre …', 'field' => '', 'id' => -1);
     }
     if (!$cached) {
         XDB::query('INSERT INTO  search_autocomplete (name, query, result, generated)
                          VALUES  ({?}, {?}, {?}, NOW())
         ON DUPLICATE KEY UPDATE  result = VALUES(result), generated = VALUES(generated)', $type, $q_normalized, $to_cache);
     }
     echo json_encode($list);
     exit;
 }
开发者ID:Ekleog,项目名称:platal,代码行数:79,代码来源:profile.php

示例13: get_event_participants

function get_event_participants(&$evt, $item_id, array $tri = array(), $limit = null, $offset = 0)
{
    global $globals;
    $eid = $evt['eid'];
    $money = $evt['money'] && function_exists('may_update') && may_update();
    $pay_id = $evt['paiement_id'];
    $append = $item_id ? XDB::format(' AND ep.item_id = {?}', $item_id) : '';
    $query = XDB::fetchAllAssoc('uid', 'SELECT  ep.uid, SUM(ep.paid) AS paid, SUM(ep.nb) AS nb,
                                                FIND_IN_SET(\'notify_payment\', ep.flags) AS notify_payment
                                          FROM  group_event_participants AS ep
                                         WHERE  ep.eid = {?} AND nb > 0 ' . $append . '
                                      GROUP BY  ep.uid', $eid);
    $uf = new UserFilter(new PFC_True(), $tri);
    $users = User::getBulkUsersWithUIDs($uf->filter(array_keys($query), new PlLimit($limit, $offset)));
    $tab = array();
    foreach ($users as $user) {
        $uid = $user->id();
        $tab[$uid] = $query[$uid];
        $tab[$uid]['user'] = $user;
    }
    if ($item_id) {
        return $tab;
    }
    $evt['adminpaid'] = 0;
    $evt['telepaid'] = 0;
    $evt['topay'] = 0;
    $evt['paid'] = 0;
    foreach ($tab as $uid => &$u) {
        $u['adminpaid'] = (double) $u['paid'];
        $u['montant'] = 0;
        if ($money && $pay_id) {
            $montant = XDB::fetchOneCell('SELECT  SUM(amount)
                                            FROM  payment_transactions AS t
                                           WHERE  status = "confirmed" AND ref = {?} AND uid = {?}', $pay_id, $uid);
            $u['paid'] += $montant;
        }
        $u['telepayment'] = $u['paid'] - $u['adminpaid'];
        $res_ = XDB::iterator('SELECT  ep.nb, ep.item_id, ei.montant
                                 FROM  group_event_participants AS ep
                           INNER JOIN  group_event_items AS ei ON (ei.eid = ep.eid AND ei.item_id = ep.item_id)
                                WHERE  ep.eid = {?} AND ep.uid = {?}', $eid, $uid);
        while ($i = $res_->next()) {
            $u[$i['item_id']] = $i['nb'];
            $u['montant'] += $i['montant'] * $i['nb'];
        }
        $evt['telepaid'] += $u['telepayment'];
        $evt['adminpaid'] += $u['adminpaid'];
        $evt['paid'] += $u['paid'];
        $evt['topay'] += $u['montant'];
    }
    return $tab;
}
开发者ID:Ekleog,项目名称:platal,代码行数:52,代码来源:xnetevents.inc.php

示例14: toCSV

 public function toCSV($sep = ',', $enc = '"', $asep = '|')
 {
     $nbq = count($this->questions);
     //require_once dirname(__FILE__) . '/../../classes/varstream.php';
     VarStream::init();
     global $csv_output;
     $csv_output = '';
     $csv = fopen('var://csv_output', 'w');
     $line = $this->isMode(self::MODE_XIDENT) ? array('id', 'Nom', 'Prenom', 'Promo') : array('id');
     $qids = array();
     for ($qid = 0; $qid < $nbq; $qid++) {
         $qids[$qid] = count($line);
         // stores the first id of a question (in case of questions with subquestions)
         array_splice($line, count($line), 0, $this->questions[$qid]->getCSVColumns());
         // the first line contains the questions
     }
     $nbf = count($line);
     $users = array();
     if ($this->isMode(self::MODE_XIDENT)) {
         // if the mode is non anonymous
         $users = User::getBulkUsersWithUIDs(XDB::fetchAllAssoc('vid', 'SELECT  v.id AS vid, v.uid
                                                                          FROM  survey_votes AS v
                                                                         WHERE  v.survey_id = {?}
                                                                      ORDER BY  vid ASC', $this->id));
     }
     $sql = 'SELECT v.id AS vid, a.question_id AS qid, a.answer AS answer
               FROM survey_votes AS v
         INNER JOIN survey_answers AS a ON a.vote_id=v.id
              WHERE v.survey_id={?}
           ORDER BY vid ASC, qid ASC, answer ASC';
     $res = XDB::iterator($sql, $this->id);
     // retrieves all answers from database
     $vid = -1;
     $vid_ = 0;
     while (($cur = $res->next()) != null) {
         if ($vid != $cur['vid']) {
             // if the vote id changes, then starts a new line
             fputcsv($csv, $line, $sep, $enc);
             // stores the former line into $csv_output
             $vid = $cur['vid'];
             $line = array_fill(0, $nbf, '');
             // creates an array full of empty string
             $line[0] = $vid_;
             // the first field is a 'clean' vote id (not the one stored in database)
             if ($this->isMode(self::MODE_XIDENT)) {
                 // if the mode is non anonymous
                 if (array_key_exists($vid, $users)) {
                     // and if the user data can be found
                     $line[1] = $users[$vid]->lastName();
                     // adds the user data (in the first fields of the line)
                     $line[2] = $users[$vid]->firstName();
                     $line[3] = $users[$vid]->promo();
                 }
             }
             $vid_++;
         }
         $ans = $this->questions[$cur['qid']]->formatAnswer($cur['answer']);
         // formats the current answer
         if (!is_null($ans)) {
             if (is_array($ans)) {
                 $fid = $qids[$cur['qid']] + $ans['id'];
                 // computes the field id
                 $a = $ans['answer'];
             } else {
                 $fid = $qids[$cur['qid']];
                 $a = $ans;
             }
             if ($line[$fid] != '') {
                 // if this field already contains something
                 $line[$fid] .= $asep;
                 // then adds a separator before adding the new answer
             }
             $line[$fid] .= $a;
             // adds the current answer to the correct field
         }
     }
     fputcsv($csv, $line, $sep, $enc);
     // stores the last line into $csv_output
     return $csv_output;
 }
开发者ID:Ekleog,项目名称:platal,代码行数:80,代码来源:old_surveys.inc.php

示例15: get

 public static function get($id, $can_be_shortname = true)
 {
     if (!$id) {
         return null;
     }
     if (!$can_be_shortname) {
         $where = XDB::format('a.id = {?}', $id);
     } else {
         $where = XDB::format('a.diminutif = {?}', $id);
     }
     $res = XDB::query('SELECT  a.*, d.nom AS domnom,
                                FIND_IN_SET(\'wiki_desc\', a.flags) AS wiki_desc,
                                FIND_IN_SET(\'notif_unsub\', a.flags) AS notif_unsub,
                                FIND_IN_SET(\'notify_all\', a.flags) AS notify_all,
                                (nls.id IS NOT NULL) AS has_nl, ad.text AS address,
                                p.display_tel AS phone, f.display_tel AS fax
                          FROM  groups AS a
                     LEFT JOIN  group_dom  AS d ON d.id = a.dom
                     LEFT JOIN  newsletters AS nls ON (nls.group_id = a.id)
                     LEFT JOIN  profile_phones AS p ON (p.link_type = \'group\' AND p.link_id = a.id AND p.tel_id = 0)
                     LEFT JOIN  profile_phones AS f ON (f.link_type = \'group\' AND f.link_id = a.id AND f.tel_id = 1)
                     LEFT JOIN  profile_addresses AS ad ON (ad.type = \'group\' AND ad.groupid = a.id)
                         WHERE  ' . $where);
     if ($res->numRows() != 1) {
         if ($can_be_shortname && (is_int($id) || ctype_digit($id))) {
             return Group::get($id, false);
         }
         return null;
     }
     $data = $res->fetchOneAssoc();
     $positions = XDB::fetchAllAssoc('SELECT  position, uid
                                        FROM  group_members
                                       WHERE  asso_id = {?} AND position IS NOT NULL
                                    ORDER BY  position', $data['id']);
     return new Group(array_merge($data, array('positions' => $positions)));
 }
开发者ID:Ekleog,项目名称:platal,代码行数:36,代码来源:group.php


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