本文整理汇总了PHP中XDB::iterRow方法的典型用法代码示例。如果您正苦于以下问题:PHP XDB::iterRow方法的具体用法?PHP XDB::iterRow怎么用?PHP XDB::iterRow使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XDB
的用法示例。
在下文中一共展示了XDB::iterRow方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Prepare
public function Prepare($page)
{
parent::Prepare($page);
$res = XDB::iterRow("SELECT sub, domain\n FROM register_subs\n WHERE uid = {?} AND type = 'list'\n ORDER BY domain", S::i('uid'));
$lists = array();
while (list($sub, $domain) = $res->next()) {
$mlist = new MailingList($sub, $domain);
list($details, ) = $mlist->getMembers();
$lists["{$sub}@{$domain}"] = $details;
}
$page->assign_by_ref('lists', $lists);
}
示例2: smarty_function_select_domains
function smarty_function_select_domains($params, &$smarty)
{
$userdomain = User::getDomainFromCookie();
$res = XDB::iterRow("SELECT f.domain\n FROM formations AS f\n LEFT JOIN studies AS s ON s.formation_id = f.formation_id\n GROUP BY f.domain\n ORDER BY COUNT(f.domain) DESC");
$sel = ' selected="selected"';
$html = "";
while (list($domain) = $res->next()) {
$isSelected = $userdomain == $domain ? $sel : "";
$html .= '<option value="' . $domain . '"' . $isSelected . '>' . $domain . '</option>' . "\n";
}
return $html;
}
示例3: handler_images
protected function handler_images(Collection $frankizimages, $size)
{
$_frankizimages = array();
foreach ($frankizimages as $frankizimage) {
$_frankizimages[$frankizimage->id()] = array();
}
$iter = XDB::iterRow("SELECT iid, size, x, y, data\n FROM images_sizes\n WHERE size IN {?} AND iid IN {?}", $fields, $frankizimages->ids());
while ($datas = $iter->next()) {
$_frankizimages[$datas['iid']][$datas['size']] = new Image($datas);
}
foreach ($frankizimages as $frankizimage) {
$frankizimage->fillFromArray(array('images' => $_frankizimages[$frankizimage->id()]));
}
}
示例4: select_nat
function select_nat($valeur, $pad = false)
{
$res = XDB::iterRow("SELECT iso_3166_1_a2 AS id, nationality AS text\n FROM geoloc_countries\n WHERE nationality IS NOT NULL\n ORDER BY nationality");
$sel = ' selected="selected"';
// on ajoute une entree vide si $pad est vrai
$html = "";
if ($pad) {
$html .= sprintf("<option value=\"\"%s> </option>\n", $valeur ? $sel : "");
}
while (list($my_id, $my_text) = $res->next()) {
$html .= sprintf("<option value=\"%s\"%s>%s</option>\n", $my_id, $valeur == $my_id ? $sel : "", $my_text ? $my_text : " ");
}
return $html;
}
示例5: value
public function value(ProfilePage $page, $field, $value, &$success)
{
if (is_null($value)) {
$value = array();
$res = XDB::iterRow("SELECT g.id, g.text\n FROM profile_binet_enum AS g\n INNER JOIN profile_binets AS i ON (i.binet_id = g.id)\n WHERE i.pid = {?}", $page->pid());
while (list($gid, $text) = $res->next()) {
$value[intval($gid)] = $text;
}
}
if (!is_array($value)) {
$value = array();
}
ksort($value);
$success = true;
return $value;
}
示例6: handler_item
protected function handler_item(Collection $validates, $fields)
{
$items = array();
foreach ($validates as $validate) {
$items[$validate->id()] = array();
}
$iter = XDB::iterRow("SELECT id, item\n FROM validate\n WHERE id IN {?}", $validates->ids());
while (list($id, $item) = $iter->next()) {
$items[$id] = unserialize($item);
}
$selects = array();
$collections = array();
foreach ($items as $item) {
foreach ($item->objects() as $field => $select) {
$hash = $select->hash();
$selects[$hash] = $select;
if (empty($collections[$hash])) {
$collections[$hash] = new Collection($select->className());
}
if ($item->{$field}() != false) {
$item->{$field}($collections[$hash]->addget($item->{$field}()));
}
}
foreach ($item->collections() as $field => $select) {
$hash = $select->hash();
$selects[$hash] = $select;
if (empty($collections[$hash])) {
$collections[$hash] = new Collection($select->className());
}
if ($item->{$field}() != false) {
$temp = new Collection($select->className());
foreach ($item->{$field}() as $f) {
$temp->add($collections[$hash]->addget($f));
}
$item->{$field}($temp);
}
}
}
foreach ($collections as $hash => $collection) {
$collection->select($selects[$hash]);
}
foreach ($validates as $validate) {
$validate->fillFromArray(array('item' => $items[$validate->id()]));
}
}
示例7: education_degree
/** affiche un Array javascript contenant les diplômes de chaque formation
*/
function education_degree()
{
$html = '';
$res = XDB::iterRow("SELECT eduid, degreeid\n FROM profile_education_degree\n ORDER BY eduid");
$edu_degree = $res->next();
for ($eduid = 1; $edu_degree; ++$eduid) {
$html .= '[';
if ($edu_degree['0'] == $eduid) {
$html .= $edu_degree['1'];
$edu_degree = $res->next();
while ($edu_degree['0'] == $eduid) {
$html .= ',' . $edu_degree['1'];
$edu_degree = $res->next();
}
}
$html .= ']';
if ($edu_degree) {
$html .= ",\n";
}
}
return $html;
}
示例8: handler_promos
protected function handler_promos(Collection $formations, $fields)
{
$_formations = array();
foreach ($formations as $f) {
$_formations[$f->id()] = array();
}
$iter = XDB::iterRow('SELECT formation_id AS id,
GROUP_CONCAT(DISTINCT promo ORDER BY promo SEPARATOR ",") AS p
FROM studies
WHERE formation_id IN {?}
GROUP BY formation_id', $formations->ids());
while (list($id, $promos) = $iter->next()) {
$promos = explode(',', $promos);
foreach ($promos as &$p) {
$p = (int) $p;
}
sort($promos);
$_formations[$id] = $promos;
}
foreach ($formations as $f) {
$f->fillFromArray(array('promos' => $_formations[$f->id()]));
}
}
示例9: check
function check($sql, $comment = '')
{
$it = XDB::iterRow($sql);
if ($err = XDB::error()) {
echo $err;
}
if ($it->total() > 0) {
echo "Erreur pour la vérification : {$comment}\n{$sql}\n\n";
echo "|";
while ($col = $it->nextField()) {
echo "\t" . $col->name . "\t|";
}
echo "\n";
while ($arr = $it->next()) {
echo "|";
foreach ($arr as $val) {
echo "\t{$val}\t|";
}
echo "\n";
}
echo "\n";
}
}
示例10: dirname
<?php
/***************************************************************************
* Copyright (C) 2004-2012 Binet Réseau *
* http://br.binets.fr/ *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* 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 dirname(__FILE__) . '/../connect.db.inc.php';
$iter = XDB::iterRow('SELECT uid, pa FROM temp');
while (list($uid, $paname) = $iter->next()) {
$pa = Group::from($paname);
$u = new User($uid);
$pa->select(GroupSelect::castes());
$pa->caste(Rights::member())->addUser($u);
echo ".";
}
echo 'Over';
// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
示例11: selectRights
public function selectRights(Collection $users)
{
$rights = array();
if ($users->count() > 0) {
$iter = XDB::iterRow('SELECT cu.uid, c.rights
FROM castes AS c
INNER JOIN castes_users AS cu ON (cu.cid = c.cid
AND (cu.visibility IN {?} OR cu.uid = {?}))
INNER JOIN groups AS g ON g.gid = c.`group`
WHERE g.gid = {?} AND cu.uid IN {?}', S::user()->visibleGids(), S::user()->id(), $this->id(), $users->ids());
while (list($uid, $right) = $iter->next()) {
if (empty($rights[$uid])) {
$rights[$uid] = array();
}
$rights[$uid][] = new Rights($right);
}
}
return $rights;
}
示例12: list_all_my_groups
function list_all_my_groups($params)
{
if (!S::logged()) {
return;
}
$res = XDB::iterRow('SELECT a.nom, a.diminutif
FROM groups AS a
INNER JOIN group_members AS m ON m.asso_id = a.id
WHERE m.uid = {?}', S::i('uid'));
$links = '<a href="exit">déconnexion</a>';
$html = '<div>Mes groupes (' . $links . ') :</div>';
while (list($nom, $mini) = $res->next()) {
$html .= "<span class='gp'>• <a href='login/{$mini}'>{$nom}</a></span>";
}
return $html;
}
示例13: elseif
} elseif ($age > 7) {
$head = "[Armageddon imminent] ";
} elseif ($age > 5) {
$head = "[Guerre nucléaire] ";
} elseif ($age > 3) {
$head = "[ET Téléphone maison] ";
} elseif ($age > 1) {
$head = "[Réveil !] ";
} elseif (!empty($nbveryold)) {
$head = "[Urgent] ";
}
if (empty($nb)) {
exit;
}
$plural = $nb == 1 ? '' : 's';
$mymail = new PlMailer();
$mymail->setFrom('validation@' . $globals->mail->domain);
$mymail->addTo('validation@' . $globals->mail->domain);
$mymail->setSubject($head . "Il y a {$nb} validation{$plural} non effectuée{$plural}");
$message = "Il y a {$nb} validation{$plural} à effectuer\n" . (empty($nbold) ? '' : "dont {$nbold} depuis le dernier mail !!!\n") . (empty($nbveryold) ? '' : "et dont *{$nbveryold}* " . ($nbveryold == 1 ? 'est' : 'sont') . ' en retard de plus de 6h !!!') . "\n" . "https://www.polytechnique.org/admin/validate\n\n" . "Par catégorie :\n";
$res = XDB::iterRow('SELECT type, count(*)
FROM requests
GROUP BY type
ORDER BY type');
while (list($type, $nb) = $res->next()) {
$message .= "- {$type} : {$nb}\n";
}
$message = wordwrap($message, 78);
$mymail->setTxtBody($message);
$mymail->send();
// vim:set et sw=4 sts=4 sws=4 foldmethod=marker fenc=utf-8:
示例14: commit
public function commit()
{
global $globals;
$email = $this->m_user->bestEmail();
XDB::execute('UPDATE email_redirect_account
SET flags = \'active\', broken_level = 2
WHERE uid = {?} AND redirect = {?}', $this->m_user->id(), $this->m_email);
if (XDB::affectedRows() > 0) {
$this->m_reactive = true;
$mailer = new PlMailer();
$mailer->setFrom('"Association Polytechnique.org" <register@' . $globals->mail->domain . '>');
$mailer->addTo($email);
$mailer->setSubject("Mise à jour de ton adresse {$email}");
$mailer->setTxtBody(wordwrap("Cher Camarade,\n\n" . "Ton adresse {$email} étant en panne et ayant été informés que ta redirection {$this->m_email}, jusqu'à présent inactive, " . "est fonctionnelle, nous venons de réactiver cette adresse.\n\n" . "N'hésite pas à aller gérer toi-même tes redirections en te rendant à la page :\n" . "https://www.polytechnique.org/emails/redirect\n" . "Si tu as perdu ton mot de passe d'accès au site, tu peux également effectuer la procédure de récupération à l'adresse :\n" . "https://www.polytechnique.org/recovery\n\n" . "-- \nTrès Cordialement,\nL'Équipe de Polytechnique.org\n"));
$mailer->send();
return true;
}
if ($this->m_user->email) {
$subject = "Ton adresse {$email} semble ne plus fonctionner";
$reason = "Nous avons été informés que ton adresse {$email} ne fonctionne plus correctement par un camarade";
} else {
$res = XDB::iterRow('SELECT redirect
FROM email_redirect_account
WHERE uid = {?} AND flags = \'broken\'', $this->m_user->id());
$redirect = array();
while (list($red) = $res->next()) {
list(, $redirect[]) = explode('@', $red);
}
$subject = "Ton adresse {$email} ne fonctionne plus";
$reason = "Ton adresse {$email} ne fonctionne plus";
if (!count($redirect)) {
$reason .= '.';
} elseif (count($redirect) == 1) {
$reason .= ' car sa redirection vers ' . $redirect[0] . ' est hors-service depuis plusieurs mois.';
} else {
$reason .= ' car ses redirections vers ' . implode(', ', $redirect) . ' sont hors-services depuis plusieurs mois.';
}
}
$body = ($this->m_user->isFemale() ? 'Chère ' : 'Cher ') . $this->m_user->displayName() . ",\n\n" . $reason . "\n\n" . "L'adresse {$this->m_email} nous a été communiquée, veux-tu que cette adresse devienne ta nouvelle " . "adresse de redirection ? Si oui, envoie nous des informations qui " . "nous permettront de nous assurer de ton identité (par exemple ta date de naissance et ta promotion).\n\n" . "-- \nTrès Cordialement,\nL'Équipe de Polytechnique.org\n";
$body = wordwrap($body, 78);
$mailer = new PlMailer();
$mailer->setFrom('"Association Polytechnique.org" <register@' . $globals->mail->domain . '>');
$mailer->addTo($this->m_email);
$mailer->setSubject($subject);
$mailer->setTxtBody($body);
return $mailer->send();
}
示例15: handler_duplicated
function handler_duplicated($page, $action = 'list', $email = null)
{
$page->changeTpl('emails/duplicated.tpl');
$states = array('pending' => 'En attente...', 'safe' => 'Pas d\'inquiétude', 'unsafe' => 'Recherches en cours', 'dangerous' => 'Usurpations par cette adresse');
$page->assign('states', $states);
if (Post::has('action')) {
S::assert_xsrf_token();
}
switch (Post::v('action')) {
case 'create':
if (trim(Post::v('emailN')) != '') {
Xdb::execute('INSERT IGNORE INTO email_watch (email, state, detection, last, uid, description)
VALUES ({?}, {?}, CURDATE(), NOW(), {?}, {?})', trim(Post::v('emailN')), Post::v('stateN'), S::i('uid'), Post::v('descriptionN'));
}
break;
case 'edit':
Xdb::execute('UPDATE email_watch
SET state = {?}, last = NOW(), uid = {?}, description = {?}
WHERE email = {?}', Post::v('stateN'), S::i('uid'), Post::v('descriptionN'), Post::v('emailN'));
break;
default:
if ($action == 'delete' && !is_null($email)) {
Xdb::execute('DELETE FROM email_watch WHERE email = {?}', $email);
}
}
if ($action != 'create' && $action != 'edit') {
$action = 'list';
}
$page->assign('action', $action);
if ($action == 'list') {
$it = XDB::iterRow('SELECT w.email, w.detection, w.state, s.email AS forlife
FROM email_watch AS w
INNER JOIN email_redirect_account AS r ON (w.email = r.redirect)
INNER JOIN email_source_account AS s ON (s.uid = r.uid AND s.type = \'forlife\')
ORDER BY w.state, w.email, s.email');
$table = array();
$props = array();
while (list($email, $date, $state, $forlife) = $it->next()) {
if (count($props) == 0 || $props['mail'] != $email) {
if (count($props) > 0) {
$table[] = $props;
}
$props = array('mail' => $email, 'detection' => $date, 'state' => $state, 'users' => array($forlife));
} else {
$props['users'][] = $forlife;
}
}
if (count($props) > 0) {
$table[] = $props;
}
$page->assign('table', $table);
} elseif ($action == 'edit') {
$it = XDB::iterRow('SELECT w.detection, w.state, w.last, w.description,
a.hruid AS edit, s.email AS forlife
FROM email_watch AS w
INNER JOIN email_redirect_account AS r ON (w.email = r.redirect)
INNER JOIN email_source_account AS s ON (s.uid = r.uid AND s.type = \'forlife\')
LEFT JOIN accounts AS a ON (w.uid = a.uid)
WHERE w.email = {?}
ORDER BY s.email', $email);
$props = array();
while (list($detection, $state, $last, $description, $edit, $forlife) = $it->next()) {
if (count($props) == 0) {
$props = array('mail' => $email, 'detection' => $detection, 'state' => $state, 'last' => $last, 'description' => $description, 'edit' => $edit, 'users' => array($forlife));
} else {
$props['users'][] = $forlife;
}
}
$page->assign('doublon', $props);
}
}