} else {
$last_seen = '0000-00-00';
}
- XDB::execute('REPLACE INTO forum_profiles (uid, sig, mail, name, flags, tree_unread, tree_read, last_seen)
- VALUES ({?}, {?}, {?}, {?}, {?}, {?}, {?}, {?})',
+ XDB::execute('INSERT INTO forum_profiles (uid, sig, mail, name, flags, tree_unread, tree_read, last_seen)
+ VALUES ({?}, {?}, {?}, {?}, {?}, {?}, {?}, {?})
+ ON DUPLICATE KEY UPDATE sig = VALUES(sig), mail = VALUES(mail), name = VALUES(name), flags = VALUES(flags),
+ tree_unread = VALUES(tree_unread), tree_read = VALUES(tree_read), last_seen = VALUES(last_seen)',
$this->user->id(), Post::v('bananasig'),
Post::v('bananamail'), Post::v('banananame'),
$flags, $unread, $read, $last_seen);
if (!isvalid_email_redirection($email_stripped)) {
return ERROR_LOOP_EMAIL;
}
- XDB::execute('REPLACE INTO emails (uid,email,flags) VALUES({?},{?},"active")', $this->user->id(), $email);
+ // If the email was already present for this user, we reset it to the default values, we thus use REPLACE INTO.
+ XDB::execute('REPLACE INTO emails (uid, email, flags)
+ VALUES ({?}, {?}, \'active\')',
+ $this->user->id(), $email);
if ($logger = S::v('log', null)) { // may be absent --> step4.php
S::logger()->log('email_add', $email . ($this->user->id() != S::v('uid') ? " (admin on {$this->user->login()})" : ""));
}
public function process(array $user)
{
- return XDB::execute("REPLACE INTO register_subs (uid, type, sub, domain)
- VALUES ({?}, 'list', {?}, {?})",
- $user['id'], $this->name, $this->domain);
+ return XDB::execute("INSERT IGNORE INTO register_subs (uid, type, sub, domain)
+ VALUES ({?}, 'list', {?}, {?})",
+ $user['id'], $this->name, $this->domain);
}
}
public function process(array $user)
{
- return XDB::execute("REPLACE INTO register_subs (uid, type, sub, domain)
- VALUES ({?}, 'group', {?}, '')",
- $user['id'], $this->group);
+ return XDB::execute("INSERT IGNORE INTO register_subs (uid, type, sub, domain)
+ VALUES ({?}, 'group', {?}, '')",
+ $user['id'], $this->group);
}
}
{
$a->_cid = ($a->_cid == 0) ? null : $a->_cid;
if ($a->_aid >= 0) {
- XDB::execute('REPLACE INTO newsletter_art (id, aid, cid, pos, title, body, append)
- VALUES ({?}, {?}, {?}, {?}, {?}, {?}, {?})',
- $this->_id, $a->_aid, $a->_cid, $a->_pos,
- $a->_title, $a->_body, $a->_append);
- $this->_arts['a' . $a->_aid] = $a;
+ XDB::execute('UPDATE newsletter_art
+ SET cid = {?}, pos = {?}, title = {?}, body = {?}, append = {?}
+ WHERE id = {?} AND aid = {?}',
+ $a->_cid, $a->_pos, $a->_title, $a->_body, $a->_append, $this->_id, $a->_aid);
} else {
- XDB::execute('INSERT INTO newsletter_art
- SELECT {?}, MAX(aid)+1, {?}, '
- . ($a->_pos ? intval($a->_pos) : 'MAX(pos)+1')
- . ', {?}, {?}, {?}
- FROM newsletter_art AS a
- WHERE a.id = {?}',
- $this->_id, $a->_cid, $a->_title, $a->_body, $a->_append, $this->_id);
- $this->_arts['a' . $a->_aid] = $a;
+ XDB::startTransaction();
+ list($aid, $pos) = XDB::fetchOneRow('SELECT MAX(aid) AS aid, MAX(pos) AS pos
+ FROM newsletter_art AS a
+ WHERE a.id = {?}',
+ $this->_id);
+ $a->_aid = ++$aid;
+ $a->_pos = ($a->_pos ? $a->_pos : ++$pos);
+ XDB::execute('INSERT INTO newsletter_art (id, aid, cid, pos, title, body, append)
+ VALUES ({?}, {?}, {?}, {?}, {?}, {?}, {?})',
+ $this->_id, $a->_aid, $a->_cid, $a->_pos,
+ $a->_title, $a->_body, $a->_append);
+ XDB::commit();
}
+ $this->_arts['a' . $a->_aid] = $a;
}
public function delArticle($aid)
static public function subscribe($uid = null)
{
$user = is_null($uid) ? S::v('uid') : $uid;
- XDB::execute("REPLACE INTO newsletter_ins (uid,last)
- VALUES ({?}, NULL)", $user);
+ XDB::execute('INSERT IGNORE INTO newsletter_ins (uid, last, hash)
+ VALUES ({?}, NULL, NULL)', $user);
}
protected function subscriptionWhere()
public static function register(Profile &$profile, $field)
{
- XDB::execute('REPLACE INTO watch_profile (pid, ts, field)
- VALUES ({?}, NOW(), {?})',
+ XDB::execute('INSERT INTO watch_profile (pid, ts, field)
+ VALUES ({?}, NOW(), {?})
+ ON DUPLICATE KEY UPDATE ts = NOW()',
$profile->id(), $field);
}
// and the next ask (if any).
private static function UpdateStatus($uid, $type_id, $status, $next_ask)
{
- XDB::execute('REPLACE INTO reminder
- SET uid = {?}, type_id = {?}, status = {?},
- remind_last = NOW(), remind_next = FROM_UNIXTIME({?})',
+ XDB::execute('INSERT INTO reminder (uid, type_id, status, remind_last, remind_next)
+ VALUES ({?}, {?}, {?}, {?}, {?})
+ ON DUPLICATE KEY UPDATE status = VALUES(status), remind_last = NOW(), remind_next = VALUES(remind_next)',
$uid, $type_id, $status,
($next_ask > 0 ? time() + $next_ask * 24 * 60 * 60 : null));
}
$user = S::user();
switch ($action) {
case 'yes':
- $res = XDB::query('SELECT id
- FROM groups
- WHERE diminutif = {?}',
- $user->profile()->yearPromo());
- $asso_id = $res->fetchOneCell();
- XDB::execute('REPLACE INTO group_members (uid, asso_id)
- VALUES ({?}, {?})',
- $user->id(), $asso_id);
+ XDB::execute('INSERT IGNORE INTO group_members (uid, asso_id)
+ SELECT {?}, id
+ FROM groups
+ WHERE diminutif = {?}'
+ $user->id(), $user->profile()->yearPromo());
$mmlist = new MMList($user);
$mmlist->subscribe('promo' . $user->profile()->yearPromo());
switch_bestalias($this->user, $this->loginbis);
if (!$this->warning) {
XDB::execute("UPDATE aliases SET type = 'homonyme', expire = NOW() WHERE alias = {?}", $this->loginbis);
- XDB::execute("REPLACE INTO homonyms (homonyme_id, uid) VALUES({?}, {?})", $this->user->id(), $this->user->id());
+ XDB::execute('INSERT IGNORE INTO homonyms (homonyme_id, uid)
+ VALUES ({?}, {?})',
+ $this->user->id(), $this->user->id());
}
return true;
public function commit ()
{
- return XDB::execute('REPLACE INTO profile_medals
- VALUES ({?}, {?}, {?})',
+ return XDB::execute('INSERT INTO profile_medals (pid, mid, gid)
+ VALUES ({?}, {?}, {?})
+ ON DUPLICATE KEY UPDATE gid = VALUES(gid)',
$this->profile->id(), $this->mid,
is_null($this->gid) ? 0 : $this->gid);
}
public function commit()
{
- XDB::execute('REPLACE INTO profile_photos (pid, attachmime, attach, x, y)
- VALUES ({?},{?},{?},{?},{?})',
+ XDB::execute('INSERT INTO profile_photos (pid, attachmime, attach, x, y)
+ VALUES ({?}, {?}, {?}, {?}, {?})
+ ON DUPLICATE KEY UPDATE attachmime = VALUES(attachmime), attach = VALUES(attach)
+ x = VALUES(x), y = VALUES(y)',
$this->profile->id(), $this->mimetype, $this->data, $this->x, $this->y);
return true;
XDB::execute("UPDATE aliases
SET type = 'homonyme', expire=NOW()
WHERE alias = {?}", $loginbis);
- XDB::execute("REPLACE INTO homonyms (homonyme_id, uid)
- VALUES ({?}, {?})", $target, $target);
+ XDB::execute('INSERT IGNORE INTO homonyms (homonyme_id, uid)
+ VALUES ({?}, {?})', $target, $target);
send_robot_homonyme($user, $loginbis);
$op = 'list';
$page->trigSuccess('Email envoyé à ' . $user->forlifeEmail() . ', alias supprimé.');
$hide[] = $cat;
}
$hide_requests = join(',', $hide);
- XDB::query('REPLACE INTO requests_hidden (uid, hidden_requests)
- VALUES ({?}, {?})',
+ XDB::query('INSERT INTO requests_hidden (uid, hidden_requests)
+ VALUES ({?}, {?})
+ ON DUPLICATE KEY UPDATE hidden_requests = VALUES(hidden_requests)',
S::v('uid'), $hide_requests);
} elseif ($hide_requests) {
foreach (explode(',', $hide_requests) as $hide_type)
break;
case 'Confirmer':
- XDB::execute("REPLACE INTO axletter
- SET id = {?}, short_name = {?}, subject = {?}, title = {?}, body = {?},
- signature = {?}, promo_min = {?}, promo_max = {?}, echeance = {?}, subset = {?}, subset_rm = {?}",
- $id, $short_name, $subject, $title, $body, $signature, $promo_min, $promo_max, $echeance, $subset ? implode("\n", $subset_to) : null, $subset_rm);
+ XDB::execute('INSERT INTO axletter (id, short_name, subject, title, body, signature,
+ promo_min, promo_max, echeance, subset, subset_rm)
+ VALUES ({?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?})
+ ON DUPLICATE KEY UPDATE short_name = VALUES(short_name), subject = VALUES(subject), title = VALUES(title),
+ body = VALUES(body), signature = VALUES(signature), promo_min = VALUES(promo_min),
+ promo_max = VALUES(promo_max), echeance = VALUES(echeance), subset = VALUES(subset),
+ subset_rm = VALUES(subset_rm)',
+ $id, $short_name, $subject, $title, $body, $signature, $promo_min, $promo_max, $echeance,
+ $subset ? implode("\n", $subset_to) : null, $subset_rm);
if (!$saved) {
global $globals;
$mailer = new PlMailer();
static public function subscribe($uid = null)
{
$user = is_null($uid) ? S::v('uid') : $uid;
- XDB::execute("REPLACE INTO axletter_ins (uid,last)
- VALUES ({?}, 0)", $user);
+ XDB::execute('INSERT IGNORE INTO axletter_ins (uid, last)
+ VALUES ({?}, 0)', $user);
}
static public function hasPerms()
case 'ajouter':
if (($contact = User::get(Env::v('user')))) {
- if (XDB::execute("REPLACE INTO contacts (uid, contact)
- VALUES ({?}, {?})",
- $uid, $contact->id())) {
+ XDB::execute('INSERT IGNORE INTO contacts (uid, contact)
+ VALUES ({?}, {?})',
+ $uid, $contact->id());
+ if (XDB::affectedRows() > 0) {
Platal::session()->updateNbNotifs();
$page->trigSuccess('Contact ajouté !');
} else {
$_POST['to_contacts'] = explode(';', @$_POST['to_contacts']);
$_POST['cc_contacts'] = explode(';', @$_POST['cc_contacts']);
$data = serialize($_POST);
- XDB::execute("REPLACE INTO email_send_save
- VALUES ({?}, {?})",
+ XDB::execute('INSERT INTO email_send_save (uid, data)
+ VALUES ({?}, {?})
+ ON DUPLICATE KEY UPDATE data = VALUES(data)',
S::user()->id('uid'), $data);
}
exit;
FROM announce_read AS ev
INNER JOIN announces AS e ON e.id = ev.evt_id
WHERE expiration < NOW()');
- XDB::execute('REPLACE INTO announce_read VALUES({?},{?})',
- $eid, S::v('uid'));
+ XDB::execute('INSERT IGNORE INTO announce_read (evt_id, uid)
+ VALUES ({?}, {?})',
+ $eid, S::v('uid'));
pl_redirect('events#'.$pound);
}
Post::v('promo_min'), Post::v('promo_max'),
$flags, $eid);
if ($upload->exists() && list($x, $y, $type) = $upload->imageInfo()) {
- XDB::execute('REPLACE INTO announce_photos
- SET eid = {?}, attachmime = {?}, x = {?}, y = {?}, attach = {?}',
- $eid, $type, $x, $y, $upload->getContents());
+ XDB::execute('INSERT INTO announce_photos (eid, attachmime, attach, x, y)
+ VALUES ({?}, {?}, {?}, {?}, {?})
+ ON DUPLICATE KEY UPDATE attachmime = VALUES(attachmime), attach = VALUES(attach), x = VALUES(x), y = VALUES(y)',
+ $eid, $type, $upload->getContents(), $x, $y);
$upload->rm();
}
}
$directoryName = $lastname . ' ' . $firstname;
++$xorgId;
- XDB::execute('REPLACE INTO profiles (hrpid, xorg_id, ax_id, sex)
- VALUES ({?}, {?}, {?}, {?})',
+ XDB::execute('INSERT INTO profiles (hrpid, xorg_id, ax_id, sex)
+ VALUES ({?}, {?}, {?}, {?})',
$hrid, $xorgId, $ax_id, $sex);
$pid = XDB::insertId();
- XDB::execute('REPLACE INTO profile_name (pid, name, typeid)
- VALUES ({?}, {?}, {?})',
+ XDB::execute('INSERT INTO profile_name (pid, name, typeid)
+ VALUES ({?}, {?}, {?})',
$pid, $lastname, $nameTypes['name_ini']);
- XDB::execute('REPLACE INTO profile_name (pid, name, typeid)
- VALUES ({?}, {?}, {?})',
+ XDB::execute('INSERT INTO profile_name (pid, name, typeid)
+ VALUES ({?}, {?}, {?})',
$pid, $firstname, $nameTypes['firstname_ini']);
- XDB::execute('REPLACE INTO profile_display (pid, yourself, public_name, private_name,
- directory_name, short_name, sort_name, promo)
- VALUES ({?}, {?}, {?}, {?}, {?}, {?}, {?}, {?})',
+ XDB::execute('INSERT INTO profile_display (pid, yourself, public_name, private_name,
+ directory_name, short_name, sort_name, promo)
+ VALUES ({?}, {?}, {?}, {?}, {?}, {?}, {?}, {?})',
$pid, $firstname, $fullName, $fullName, $directoryName, $fullName, $directoryName, $promo);
- XDB::execute('REPLACE INTO profile_education (pid, eduid, degreeid, entry_year, grad_year, flags)
- VALUES ({?}, {?}, {?}, {?}, {?}, {?})',
+ XDB::execute('INSERT INTO profile_education (pid, eduid, degreeid, entry_year, grad_year, flags)
+ VALUES ({?}, {?}, {?}, {?}, {?}, {?})',
$pid, $eduSchools[Profile::EDU_X], $degreeid, $entry_year, $grad_year, 'primary');
- XDB::execute('REPLACE INTO accounts (hruid, type, is_admin, state, full_name, directory_name, display_name, sex)
- VALUES ({?}, {?}, {?}, {?}, {?}, {?}, {?})',
+ XDB::execute('INSERT INTO accounts (hruid, type, is_admin, state, full_name, directory_name, display_name, sex)
+ VALUES ({?}, {?}, {?}, {?}, {?}, {?}, {?})',
$hrid, $type, 0, 'active', $fullName, $directoryName, $lastname, $sex);
$uid = XDB::insertId();
- XDB::execute('REPLACE INTO account_profiles (uid, pid, perms)
- VALUES ({?}, {?}, {?})',
+ XDB::execute('INSERT INTO account_profiles (uid, pid, perms)
+ VALUES ({?}, {?}, {?})',
$uid, $pid, 'owner');
}
$report[] = 'Promo 1920 ajoutée.';
$page->trigError('URL invalide');
} else {
$url = Env::t('url');
- XDB::execute('REPLACE INTO carvas (uid, url)
- VALUES ({?}, {?})',
+ XDB::execute('INSERT INTO carvas (uid, url)
+ VALUES ({?}, {?})
+ ON DUPLICATE KEY UPDATE url = VALUES(url)',
S::i('uid'), $url);
S::logger()->log('carva_add', 'http://' . $url);
$page->trigSuccess("Redirection activée vers <a href='http://$url'>$url</a>");
}
$res .= "\n";
}
- XDB::query('REPLACE INTO search_autocomplete
- VALUES ({?}, {?}, {?}, NOW())',
+ XDB::query('INSERT INTO search_autocomplete (name, query, result, generated)
+ VALUES ({?}, {?}, {?}, NOW())
+ ON DUPLICATE KEY result = VALUES(result), generated = NOW()',
$type, $q_normalized, $res);
echo $res;
exit();
S::assert_xsrf_token();
$data = file_get_contents($_FILES['userfile']['tmp_name']);
- list($x, $y) = getimagesize($_FILES['userfile']['tmp_name']);
- $mimetype = substr($_FILES['userfile']['type'], 6);
- unlink($_FILES['userfile']['tmp_name']);
- XDB::execute(
- "REPLACE INTO profile_photos SET pid={?}, attachmime = {?}, attach={?}, x={?}, y={?}",
- $user->profile()->id(), $mimetype, $data, $x, $y);
- break;
+ list($x, $y) = getimagesize($_FILES['userfile']['tmp_name']);
+ $mimetype = substr($_FILES['userfile']['type'], 6);
+ unlink($_FILES['userfile']['tmp_name']);
+ XDB::execute('INSERT INTO profile_photos (pid, attachmime, attach, x, y)
+ VALUES ({?}, {?}, {?}, {?}, {?})
+ ON DUPLICATE KEY UPDATE attachmime = VALUES(attachmime), attach = VALUES(attach), x = VALUES(x), y = VALUES(y)',
+ $user->profile()->id(), $mimetype, $data, $x, $y);
+ break;
case "delete":
S::assert_xsrf_token();
}
}
if (count($terms_values) > 0) {
- XDB::execute('REPLACE INTO profile_job_term (pid, jid, jtid, computed)
- VALUES '.implode(', ', $terms_values));
+ XDB::rawExecute('INSERT INTO profile_job_term (pid, jid, jtid, computed)
+ VALUES ' . implode(', ', $terms_values) . '
+ ON DUPLICATE KEY UPDATE computed = VALUES(computed)');
}
}
public function save(ProfilePage &$page, $field, $value)
{
- XDB::execute('REPLACE INTO profile_corps (original_corpsid, current_corpsid, rankid, corps_pub, pid)
- VALUES ({?}, {?}, {?}, {?}, {?})',
+ XDB::execute('INSERT INTO profile_corps (original_corpsid, current_corpsid, rankid, corps_pub, pid)
+ VALUES ({?}, {?}, {?}, {?}, {?})
+ ON DUPLICATE KEY UPDATE original_corpsid = VALUES(original_corpsid), current_corpsid = VALUES(current_corpsid)
+ rankid = VALUES(rankid), corps_pub = VALUES(corps_pub)',
$value['original'], $value['current'], $value['rank'], $value['pub'], $page->pid());
}
$this->pid());
$this->values['expertise'] = null;
} else {
- XDB::execute("REPLACE INTO profile_mentor (pid, expertise)
- VALUES ({?}, {?})",
+ XDB::execute('INSERT INTO profile_mentor (pid, expertise)
+ VALUES ({?}, {?})
+ ON DUPLICATE KEY UPDATE expertise = VALUES(expertise)',
$this->pid(), $expertise);
$this->values['expertise'] = $expertise;
}
$user = S::user();
if ($owner->isActive() && $owner->id() != $user->id()) {
foreach ($changedFields as $field => $values) {
- XDB::execute('REPLACE INTO profile_modifications (pid, uid, field, oldText, newText)
- VALUES ({?}, {?}, {?}, {?}, {?})',
+ XDB::execute('INSERT INTO profile_modifications (pid, uid, field, oldText, newText)
+ VALUES ({?}, {?}, {?}, {?}, {?})
+ ON DUPLICATE KEY UPDATE oldText = VALUES(oldText), newText = VALUES(newText)',
$this->pid(), $user->id(), $field, $values[0], $values[1]);
}
}
$subState->merge($res->fetchOneRow());
$subState->set('yearpromo', substr($subState->s('promo'), 1, 4));
- XDB::execute('REPLACE INTO register_mstats (uid,sender,success)
- SELECT m.uid, m.sender, 0
- FROM register_marketing AS m
- WHERE m.hash',
+ XDB::execute('INSERT INTO register_mstats (uid, sender, success)
+ SELECT m.uid, m.sender, 0
+ FROM register_marketing AS m
+ WHERE m.hash
+ ON DUPLICATE KEY sender = VALUES(sender), success = VALUES(success)',
$subState->s('hash'));
}
}
$r = XDB::query('SELECT id FROM groups WHERE diminutif = {?}', $yearpromo);
if ($r->numRows()) {
$asso_id = $r->fetchOneCell();
- XDB::execute('REPLACE INTO group_members (uid, asso_id)
- VALUES ({?}, {?})',
+ XDB::execute('INSERT INTO group_members (uid, asso_id)
+ VALUES ({?}, {?})',
$uid, $asso_id);
$mmlist = new MMList($uid, S::v('password'));
$mmlist->subscribe("promo" . S::v('promo'));
Profile::rebuildSearchTokens($pid);
// Notify other users which were watching for her arrival.
- XDB::execute('REPLACE INTO contacts (uid, contact)
- SELECT uid, ni_id
- FROM watch_nonins
- WHERE ni_id = {?}', $uid);
+ XDB::execute('INSERT INTO contacts (uid, contact)
+ SELECT uid, ni_id
+ FROM watch_nonins
+ WHERE ni_id = {?}', $uid);
XDB::execute('DELETE FROM watch_nonins
WHERE ni_id = {?}', $uid);
Platal::session()->updateNbNotifs();
XDB::execute('UPDATE aliases
SET expire = ADDDATE(NOW(), INTERVAL 1 MONTH)
WHERE alias = {?}', $emailXorg);
- XDB::execute('REPLACE INTO homonyms (homonyme_id, uid)
- VALUES ({?}, {?})', $subState->i('uid'), $h_id);
- XDB::execute('REPLACE INTO homonyms (homonyme_id, uid)
- VALUES ({?}, {?})', $h_id, $subState->i('uid'));
+ XDB::execute('INSERT IGNORE INTO homonyms (homonyme_id, uid)
+ VALUES ({?}, {?}), ({?}, {?})',
+ $subState->i('uid'), $h_id, $h_id, $subState->i('uid'));
$res = XDB::query('SELECT alias
FROM aliases
WHERE uid = {?} AND expire IS NULL', $h_id);
global $globals;
$hash = rand_url_id(12);
- XDB::execute('REPLACE INTO register_pending (uid, forlife, bestalias, mailorg2, password,
- email, date, relance, naissance, hash, services)
- VALUES ({?}, {?}, {?}, {?}, {?}, {?}, NOW(), 0, {?}, {?}, {?})',
+ XDB::execute('INSERT INTO register_pending (uid, forlife, bestalias, mailorg2, password,
+ email, date, relance, naissance, hash, services)
+ VALUES ({?}, {?}, {?}, {?}, {?}, {?}, NOW(), 0, {?}, {?}, {?})',
$subState->i('uid'), $subState->s('forlife'), $subState->s('bestalias'),
$subState->s('emailXorg2'), $subState->s('password'), $subState->s('email'),
$subState->s('birthdate'), $hash, implode(',', $subState->v('services')));
if ($nbResults == 0) {
$res = $q."|-2\n";
}
- XDB::query('REPLACE INTO search_autocomplete
- VALUES ({?}, {?}, {?}, NOW())',
- $type, $q, $res);
+ XDB::query('INSERT INTO search_autocomplete (name, query, result, generated)
+ VALUES ({?}, {?}, {?}, NOW())
+ ON DUPLICATE KEY result = VALUES(result), generated = NOW()',
+ $type, $q, $res);
echo $res;
exit();
}
$telepaid= $evt['telepaid'] ? $evt['telepaid'] : 0;
foreach ($subs as $j => $nb) {
if ($nb >= 0) {
- $tmp_flags = (Env::has('notify_payment') ? 'notify_payment' : '');
- $tmp_paid = ($j == 1 ? $paid - $telepaid : 0);
XDB::execute('INSERT INTO group_event_participants (eid, uid, item_id, nb, flags, paid)
VALUES ({?}, {?}, {?}, {?}, {?}, {?})
- ON DUPLICATE KEY UPDATE nb = {?}, flags = {?}, paid = {?}',
- $eid, S::v('uid'), $j, $nb, $tmp_flags, $tmp_paid,
- $nb, $tmp_flags, $tmp_paid);
+ ON DUPLICATE KEY UPDATE nb = VALUES(nb), flags = VALUES(flags), paid = VALUES(paid)',
+ $eid, S::v('uid'), $j, $nb, (Env::has('notify_payment') ? 'notify_payment' : ''),
+ ($j == 1 ? $paid - $telepaid : 0));
$updated = $eid;
} else {
XDB::execute(
short_name, deadline_inscription, noinvite,
accept_nonmembre)
VALUES ({?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?})
- ON DUPLICATE KEY UPDATE asso_id = {?}, uid = {?}, intitule = {?},
- paiement_id = {?}, descriptif = {?}, debut = {?},
- fin = {?}, show_participants = {?}, short_name = {?},
- deadline_inscription = {?}, noinvite = {?}',
+ ON DUPLICATE KEY UPDATE asso_id = VALUES(asso_id), uid = VALUES(uid), intitule = VALUES(intitule),
+ paiement_id = VALUES(paiement_id), descriptif = VALUES(descriptif), debut = VALUES(debut),
+ fin = VALUES(fin), show_participants = VALUES(show_participants), short_name = VALUES(short_name),
+ deadline_inscription = VALUES(deadline_inscription), noinvite = VALUES(noinvite)',
$evt['eid'], $evt['asso_id'], $evt['uid'],
$evt['intitule'], $evt['paiement_id'], $evt['descriptif'],
$evt['debut'], $evt['fin'], $evt['show_participants'],
$evt['short_name'], $evt['deadline_inscription'],
- $evt['noinvite'], $evt['accept_nonmembre'],
- $evt['asso_id'], $evt['uid'],
- $evt['intitule'], $evt['paiement_id'], $evt['descriptif'],
- $evt['debut'], $evt['fin'], $evt['show_participants'],
- $evt['short_name'], $evt['deadline_inscription'],
- $evt['noinvite'], $evt['accept_nonmembre'], $evt['eid']);
+ $evt['noinvite'], $evt['accept_nonmembre']);
// if new event, get its id
if (!$eid) {
$money_defaut += (float)$montant;
XDB::execute('INSERT INTO group_event_items (eid, item_id, titre, details, montant)
VALUES ({?}, {?}, {?}, {?}, {?})
- ON DUPLICATE KEY UPDATE titre = {?}, details = {?}, montant = {?}',
- $eid, $i, Post::v('titre' . $i), Post::v('details' . $i), $montant,
- Post::v('titre' . $i), Post::v('details' . $i), $montant);
+ ON DUPLICATE KEY UPDATE titre = VALUES(titre), details = VALUES(details), montant = VALUES(montant)',
+ $eid, $i, Post::v('titre' . $i), Post::v('details' . $i), $montant);
} else {
XDB::execute('DELETE FROM group_event_items
WHERE eid = {?} AND item_id = {?}', $eid, $i);
$nb = max(intval($nb), 0);
XDB::execute('INSERT INTO group_event_participants (eid, uid, item_id, nb, flags, paid)
VALUES ({?}, {?}, {?}, {?}, {?}, {?})
- ON DUPLICATE KEY UPDATE nb = {?}, flags = {?}, paid = {?}',
- $evt['eid'], $member->uid, $id, $nb, '', ($id == 1 ? $paid : 0),
- $nb, '', ($id == 1 ? $paid : 0));
+ ON DUPLICATE KEY UPDATE nb = VALUES(nb), flags = VALUES(flags), paid = VALUES(paid)',
+ $evt['eid'], $member->uid, $id, $nb, '', ($id == 1 ? $paid : 0));
}
$res = XDB::query('SELECT COUNT(uid) AS cnt, SUM(nb) AS nb
function subscribe($list, $email)
{
if ($list && $email) {
- XDB::execute('REPLACE INTO virtual_redirect
- VALUES ({?}, {?})',
+ XDB::execute('INSERT IGNORE INTO virtual_redirect
+ VALUES ({?}, {?})',
$list, $email);
}
}
}
if ($user) {
- XDB::execute('REPLACE INTO group_members (uid, asso_id)
- VALUES ({?}, {?})',
+ XDB::execute('INSERT IGNORE INTO group_members (uid, asso_id)
+ VALUES ({?}, {?})',
$user->id(), $globals->asso('id'));
$this->removeSubscriptionRequest($user->id());
pl_redirect('member/' . $user->login());
$art['id'], $globals->asso('id'));
if ($art['photo'] && $upload->exists()) {
list($imgx, $imgy, $imgtype) = $upload->imageInfo();
- XDB::execute("REPLACE INTO group_announces_photo
- SET eid = {?}, attachmime = {?}, x = {?}, y = {?}, attach = {?}",
- $aid, $imgtype, $imgx, $imgy, $upload->getContents());
+ XDB::execute('INSERT INTO group_announces_photo (eid, attachmime, attach, x, y)
+ VALUES ({?}, {?}, {?}, {?}, {?})
+ ON DUPLICATE KEY UPDATE attachmime = VALUES(attachmime), attach = VALUES(attach), x = VALUES(x), y = VALUES(y)',
+ $aid, $imgtype, $upload->getContents(), $imgx, $imgy);
$upload->rm();
}
}