本文整理汇总了PHP中XDB::execute方法的典型用法代码示例。如果您正苦于以下问题:PHP XDB::execute方法的具体用法?PHP XDB::execute怎么用?PHP XDB::execute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XDB
的用法示例。
在下文中一共展示了XDB::execute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: commit
public function commit()
{
$hash = rand_url_id(12);
XDB::execute('INSERT INTO register_pending_xnet (uid, hruid, email, date, hash, sender_name, group_name)
VALUES ({?}, {?}, {?}, NOW(), {?}, {?}, {?})', $this->uid, $this->hruid, $this->email, $hash, $this->user->fullName(), $this->group);
return true;
}
示例2: commit
public function commit()
{
$sql = 'INSERT INTO surveys
SET questions = {?}, title = {?}, description = {?},
uid = {?}, end = {?},mode = {?}, promos = {?}';
return XDB::execute($sql, serialize($this->questions), $this->title, $this->description, $this->user->id(), $this->end, $this->mode, $this->promos);
}
示例3: query
function query($sql)
{
XDB::execute($sql);
if (XDB::errno() != 0) {
echo "error in \"{$sql}\":\n", XDB::error(), "\n";
}
}
示例4: commit
public function commit()
{
if ($this->user->hasProfile()) {
XDB::execute('UPDATE profiles
SET alias_pub = {?}
WHERE pid = {?}', $this->public, $this->user->profile()->id());
}
if ($this->old) {
$success = XDB::execute('UPDATE email_source_account
SET email = {?}
WHERE uid = {?} AND type = \'alias_aux\'', $this->alias, $this->user->id());
} else {
$success = XDB::execute('INSERT INTO email_source_account (email, uid, domain, type, flags)
SELECT {?}, {?}, id, \'alias_aux\', \'\'
FROM email_virtual_domains
WHERE name = {?}', $this->alias, $this->user->id(), Platal::globals()->mail->alias_dom);
}
if ($success) {
// Update the local User object, to pick up the new bestalias.
require_once 'emails.inc.php';
fix_bestalias($this->user);
$this->user = User::getSilentWithUID($this->user->id());
}
return $success;
}
示例5: do_update_by_block
function do_update_by_block($values)
{
// Update display_tel by block
// Because there is no mysql update syntax for multiple updates in one query
// we use a multiple insert syntax which will fail because the key already exist
// and then update the display_tel
XDB::execute("INSERT INTO profile_phones (pid, link_type, link_id, tel_id ,tel_type,\n search_tel, display_tel, pub, comment)\n VALUES " . $values . "\n ON DUPLICATE KEY UPDATE display_tel = VALUES(display_tel)");
}
示例6: purgeOrphanedEvents
/**
* Purges session events without a valid session.
*/
function purgeOrphanedEvents()
{
$begin = time();
XDB::execute("DELETE e\n FROM log_events AS e\n LEFT JOIN log_sessions AS s ON (s.id = e.session)\n WHERE s.id IS NULL");
$affectedRows = XDB::affectedRows();
$duration = time() - $begin;
echo "Orphaned events: removed {$affectedRows} events in {$duration} seconds.\n";
}
示例7: handler_ajax_todo_clear
function handler_ajax_todo_clear($page)
{
S::assert_xsrf_token();
XDB::execute('DELETE FROM todo
WHERE uid = {?} AND checked = 1', S::user()->id());
if (XDB::affectedRows() != 1) {
$page->jsonAssign('error', "Impossible de nettoyer la liste des tâches");
}
return PL_JSON;
}
示例8: save
public function save(ProfilePage $page, $field, $value)
{
XDB::execute("DELETE FROM profile_binets\n WHERE pid = {?}", $page->pid());
if (!count($value)) {
return;
}
$insert = array();
foreach ($value as $id => $text) {
$insert[] = XDB::format('({?}, {?})', $page->pid(), $id);
}
XDB::execute("INSERT INTO profile_binets (pid, binet_id)\n VALUES " . implode(',', $insert));
}
示例9: fix_homonym
function fix_homonym(PlUser $user, $email)
{
XDB::execute('DELETE FROM email_source_account
WHERE email = {?} AND type = \'alias\'', $email);
$hrmid = User::makeHomonymHrmid($email);
// TODO: insert twice into source_other if different domains
XDB::execute('INSERT INTO email_source_other (hrmid, email, domain, type, expire)
SELECT {?}, {?}, id, \'homonym\', NOW()
FROM email_virtual_domains
WHERE name = {?}', $hrmid, $email, $user->mainEmailDomain());
XDB::execute("INSERT INTO email_redirect_other (hrmid, redirect, type, action)\n VALUES ({?}, '', 'homonym', 'homonym')", $hrmid);
require_once 'emails.inc.php';
fix_bestalias($user);
}
示例10: getComponentId
public static function getComponentId(array $component)
{
$where = '';
foreach ($component['types'] as $type) {
$where .= XDB::format(' AND FIND_IN_SET({?}, types)', $type);
}
$id = XDB::fetchOneCell('SELECT id
FROM profile_addresses_components_enum
WHERE short_name = {?} AND long_name = {?}' . $where, $component['short_name'], $component['long_name']);
if (is_null($id)) {
XDB::execute('INSERT INTO profile_addresses_components_enum (short_name, long_name, types)
VALUES ({?}, {?}, {?})', $component['short_name'], $component['long_name'], implode(',', $component['types']));
$id = XDB::insertId();
}
return $id;
}
示例11: _saveData
protected function _saveData()
{
if ($this->changed['message']) {
$message = trim($this->values['message']);
if (empty($message)) {
XDB::execute('DELETE FROM profile_deltaten
WHERE pid = {?}', $this->pid());
$this->values['message'] = null;
} else {
XDB::execute('INSERT INTO profile_deltaten (pid, message)
VALUES ({?}, {?})
ON DUPLICATE KEY UPDATE message = VALUES(message)', $this->pid(), $message);
$this->values['message'] = $message;
}
}
}
示例12: 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();
}
示例13: handler_admin_url
function handler_admin_url($page)
{
$page->changeTpl('urlshortener/admin.tpl');
if (!Post::has('url')) {
return;
}
$url = Post::t('url');
$alias = Post::t('alias');
$url_regex = '{^(https?|ftp)://[a-zA-Z0-9._%#+/?=&~-]+$}i';
if (strlen($url) > 255 || !preg_match($url_regex, $url)) {
$page->trigError("L'url donnée n'est pas valide.");
return;
}
$page->assign('url', $url);
if ($alias != '') {
if (!preg_match('/^[a-zA-Z0-9\\-\\/]+$/i', $alias)) {
$page->trigError("L'alias proposé n'est pas valide.");
return;
}
if (preg_match('/^a\\//i', $alias)) {
$page->trigError("L'alias commence par le préfixe 'a/' qui est réservé et donc non autorisé.");
return;
}
$page->assign('alias', $alias);
$used = XDB::fetchOneCell('SELECT COUNT(*)
FROM url_shortener
WHERE alias = {?}', $alias);
if ($used != 0) {
$page->trigError("L'alias proposé est déjà utilisé.");
return;
}
} else {
do {
$alias = 'a/' . rand_token(6);
$used = XDB::fetchOneCell('SELECT COUNT(*)
FROM url_shortener
WHERE alias = {?}', $alias);
} while ($used != 0);
$page->assign('alias', $alias);
}
XDB::execute('INSERT INTO url_shortener (url, alias)
VALUES ({?}, {?})', $url, $alias);
$page->trigSuccess("L'url « " . $url . ' » est maintenant accessible depuis « http://u.w4x.org/' . $alias . ' ».');
}
示例14: HandleAction
public function HandleAction($action)
{
$user = S::user();
switch ($action) {
case 'yes':
XDB::execute('INSERT IGNORE INTO group_members (uid, asso_id)
SELECT {?}, id
FROM groups
WHERE diminutif = {?}', $user->id(), $user->profile()->yearPromo());
MailingList::subscribePromo($user->profile()->yearPromo());
$this->UpdateOnYes();
break;
case 'dismiss':
$this->UpdateOnDismiss();
break;
case 'no':
$this->UpdateOnNo();
break;
}
}
示例15: update_private
function update_private($data, $string, $pid, &$aliases, $perform_updates)
{
// We here assume there are no other last/firstnames as there do not seem to be any in the db.
$string = substr($string, 1, strlen($string) - 2);
$string = substr($string, 6, strlen($string) - 6);
if (!isset($aliases[$pid])) {
if ($perform_updates) {
XDB::execute("INSERT INTO profile_private_names (pid, type, id, name)\n VALUES ({?}, 'nickname', 0, {?})", $pid, $string);
} else {
print $string . ' (alias for pid ' . $pid . ")\n";
}
} elseif ($aliases[$pid] != $string) {
if ($perform_updates) {
XDB::execute('UPDATE profile_private_names
SET name = {?}
WHERE pid = {?} AND name = {?}', $string, $pid, $aliases[$pid]);
} else {
print $string . ' (new alias for pid ' . $pid . ' replacing ' . $aliases[$pid] . ")\n";
}
}
}