本文整理汇总了PHP中XDB::insertId方法的典型用法代码示例。如果您正苦于以下问题:PHP XDB::insertId方法的具体用法?PHP XDB::insertId怎么用?PHP XDB::insertId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XDB
的用法示例。
在下文中一共展示了XDB::insertId方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: writeSession
/** Creates a new session entry in database and return its ID.
*
* @param $uid the id of the logged user
* @param $suid the id of the administrator who has just su'd to the user
* @return session the session id
*/
private function writeSession($uid, $suid = null)
{
$ip = $_SERVER['REMOTE_ADDR'];
$host = strtolower(gethostbyaddr($_SERVER['REMOTE_ADDR']));
$browser = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '';
@(list($forward_ip, ) = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']));
$forward_host = $forward_ip;
if ($forward_host) {
$forward_host = strtolower(gethostbyaddr($forward_host));
}
$proxy = '';
if ($forward_ip || @$_SERVER['HTTP_VIA']) {
$proxy = 'proxy';
}
$uid = $uid == 0 ? null : $uid;
$suid = $suid == 0 ? null : $suid;
XDB::execute("INSERT INTO log_sessions\n SET uid={?}, host={?}, ip={?}, forward_ip={?}, forward_host={?}, browser={?}, suid={?}, flags={?}", $uid, $host, ip_to_uint($ip), ip_to_uint($forward_ip), $forward_host, $browser, $suid, $proxy);
if ($forward_ip) {
$this->proxy_ip = $ip;
$this->proxy_host = $host;
$this->ip = $forward_ip;
$this->host = $forward_host;
} else {
$this->ip = $ip;
$this->host = $host;
}
return XDB::insertId();
}
示例2: insert
public function insert()
{
XDB::execute('INSERT qdj
SET question = {?}, answer1 = {?}, answer2 = {?},
count1 = 0, count2 = 0, writer = {?}', $this->question, $this->answer1, $this->answer2, $this->writer->id());
$this->id = XDB::insertId();
}
示例3: handler_ajax_todo_add
function handler_ajax_todo_add($page)
{
S::assert_xsrf_token();
if (Json::has('tobedone')) {
XDB::execute('INSERT INTO todo
SET uid = {?}, sent = NOW(), checked = 0, tobedone = {?}', S::user()->id(), Json::s('tobedone'));
if (XDB::affectedRows() > 0) {
$page->jsonAssign('todo_id', XDB::insertId());
} else {
$page->jsonAssign('error', "Impossible d'ajouter une nouvelle tâche");
}
} else {
$page->jsonAssign('error', "Requête invalide");
}
return PL_JSON;
}
示例4: 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;
}
示例5: xml_parser_create
$parser = xml_parser_create();
xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);
xml_parse_into_struct($parser, $data, $values, $tags);
xml_parser_free($parser);
XDB::execute('INSERT INTO `profile_job_term_enum` (`name`, `full_name`) VALUES ("Emplois", "Emplois")');
$opened_nodes = array();
$broader_ids = array(XDB::insertId());
XDB::execute('INSERT INTO profile_job_term_relation VALUES (0, {?}, "narrower", "original"), ({?}, {?}, "narrower", "computed")', $broader_ids[0], $broader_ids[0], $broader_ids[0]);
// loop through the structures
foreach ($values as $val) {
if (($val['type'] == 'open' || $val['type'] == 'complete') && !empty($val['attributes']['intitule'])) {
$intitule = $val['attributes']['intitule'];
if (mb_strtoupper($intitule) == $intitule) {
$intitule = ucfirst(mb_strtolower($intitule));
}
$res = XDB::execute('INSERT INTO profile_job_term_enum (name, full_name)
VALUES ({?}, {?})', $intitule, $intitule . ' (emploi' . ($val['type'] == 'open' ? 's' : '') . ')');
$newid = XDB::insertId();
array_unshift($broader_ids, $newid);
array_unshift($opened_nodes, $val['tag']);
foreach ($broader_ids as $i => $bid) {
XDB::execute('INSERT INTO profile_job_term_relation VALUES ({?}, {?}, "narrower", {?})', $bid, $newid, $i == 1 ? 'original' : 'computed');
}
}
if (count($opened_nodes) > 0 && $val['tag'] == $opened_nodes[0] && ($val['type'] == 'close' || $val['type'] == 'complete')) {
array_shift($broader_ids);
array_shift($opened_nodes);
}
}
/* vim:set et sw=4 sts=4 ts=4: */
示例6: insert
public function insert()
{
XDB::execute('INSERT activities
SET target = {?}, origin = {?}, title = {?},
description = {?}, days = {?}, default_begin = {?},
default_end = {?}', $this->target->id(), !$this->origin ? null : $this->origin->id(), $this->title, $this->description, $this->days, $this->default_begin, $this->default_end);
$this->id = XDB::insertId();
}
示例7: handler_import
//.........这里部分代码省略.........
$lines = explode("\n", $q);
$l = $lines[0];
$report[] = addslashes($l);
}
// exécute la requête
$res = $db->query(str_replace('{?}', $spoolpath, $q));
if ($res === false) {
throw new XDBException($q, $db->error);
}
}
}
$db->close();
// trouve le prochain fichier à exécuter
$nextfile = $file + 1;
} else {
$nextfile = 0;
}
if ($nextfile > 5) {
// tous les fichiers ont été exécutés, on passe à l'étape suivante
$next = 'adds1920';
} else {
// on passe au fichier suivant
$next = 'integrateSQL/' . $nextfile;
}
} elseif ($action == 'adds1920') {
// Adds promotion 1920 from AX db.
$report[] = 'Ajout de la promotion 1920';
$res = XDB::iterator('SELECT prenom, Nom_complet, ax_id
FROM fusionax_anciens
WHERE promotion_etude = 1920;');
$eduSchools = DirEnum::getOptions(DirEnum::EDUSCHOOLS);
$eduSchools = array_flip($eduSchools);
$eduDegrees = DirEnum::getOptions(DirEnum::EDUDEGREES);
$eduDegrees = array_flip($eduDegrees);
$degreeid = $eduDegrees[Profile::DEGREE_X];
$entry_year = 1920;
$grad_year = 1923;
$promo = 'X1920';
$hrpromo = '1920';
$sex = 'male';
$xorgId = 19200000;
$type = 'x';
while ($new = $res->next()) {
$firstname = $new['prenom'];
$lastname = $new['Nom_complet'];
$ax_id = $new['ax_id'];
$hrid = User::makeHrid($firstname, $lastname, $hrpromo);
$res1 = XDB::query('SELECT COUNT(*)
FROM accounts
WHERE hruid = {?}', $hrid);
$res2 = XDB::query('SELECT COUNT(*)
FROM profiles
WHERE hrpid = {?}', $hrid);
if (is_null($hrid) || $res1->fetchOneCell() > 0 || $res2->fetchOneCell() > 0) {
$report[] = $ax_id . ' non ajouté';
}
$fullName = $firstname . ' ' . $lastname;
$directoryName = $lastname . ' ' . $firstname;
++$xorgId;
XDB::execute('INSERT INTO profiles (hrpid, xorg_id, ax_id, sex)
VALUES ({?}, {?}, {?}, {?})', $hrid, $xorgId, $ax_id, $sex);
$pid = XDB::insertId();
XDB::execute('INSERT INTO profile_public_names (pid, lastname_initial, firstname_initial, lastname_main, firstname_main)
VALUES ({?}, {?}, {?}, {?}, {?})', $pid, $lastname, $firstname, $lastname, $firstname);
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('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('INSERT INTO accounts (hruid, type, is_admin, state, full_name, directory_name, display_name, lastname, firstname, sex)
VALUES ({?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?})', $hrid, $type, 0, 'pending', $fullName, $directoryName, $firstname, $lastname, $firstname, $sex);
$uid = XDB::insertId();
XDB::execute('INSERT INTO account_profiles (uid, pid, perms)
VALUES ({?}, {?}, {?})', $uid, $pid, 'owner');
}
$report[] = 'Promo 1920 ajoutée.';
$next = 'view';
} elseif ($action == 'view') {
XDB::execute('CREATE OR REPLACE ALGORITHM=MERGE VIEW fusionax_xorg_anciens AS
SELECT p.pid, p.ax_id, pd.promo, pd.private_name, pd.public_name,
pd.sort_name, pd.short_name, pd.directory_name
FROM profiles AS p
INNER JOIN profile_display AS pd ON (pd.pid = p.pid)');
$next = 'clean';
} elseif ($action == 'clean') {
// nettoyage du fichier temporaire
//exec('rm -Rf ' . $spoolpath);
$report[] = 'Import finit.';
}
foreach ($report as $t) {
// affiche les lignes de report
echo "\$('#fusionax').append('" . $t . "<br/>');\n";
}
if (isset($next)) {
// lance le prochain script s'il y en a un
echo "\$.getScript('fusionax/import/" . $next . "');";
}
// exit pour ne pas afficher la page template par défaut
exit;
}
示例8: handler_add_accounts
function handler_add_accounts($page, $action = null, $promo = null)
{
require_once 'name.func.inc.php';
$page->changeTpl('admin/add_accounts.tpl');
if (Env::has('add_type') && Env::has('people')) {
static $titles = array('male' => 'M', 'female' => 'MLLE');
$lines = explode("\n", Env::t('people'));
$separator = Env::t('separator');
$promotion = Env::i('promotion');
if (Env::t('add_type') == 'promo') {
$eduSchools = DirEnum::getOptions(DirEnum::EDUSCHOOLS);
$eduSchools = array_flip($eduSchools);
$eduDegrees = DirEnum::getOptions(DirEnum::EDUDEGREES);
$eduDegrees = array_flip($eduDegrees);
switch (Env::t('edu_type')) {
case 'X':
$degreeid = $eduDegrees[Profile::DEGREE_X];
$entry_year = $promotion;
$grad_year = $promotion + 3;
$promo = 'X' . $promotion;
$hrpromo = $promotion;
$type = 'x';
break;
case 'M':
$degreeid = $eduDegrees[Profile::DEGREE_M];
$grad_year = $promotion;
$entry_year = $promotion - 2;
$promo = 'M' . $promotion;
$hrpromo = $promo;
$type = 'master';
break;
case 'D':
$degreeid = $eduDegrees[Profile::DEGREE_D];
$grad_year = $promotion;
$entry_year = $promotion - 3;
$promo = 'D (en cours)';
$hrpromo = 'D' . $promotion;
$type = 'phd';
break;
default:
$page->killError("La formation n'est pas reconnue : " . Env::t('edu_type') . '.');
}
$best_domain = XDB::fetchOneCell('SELECT id
FROM email_virtual_domains
WHERE name = {?}', User::$sub_mail_domains[$type] . Platal::globals()->mail->domain);
XDB::startTransaction();
foreach ($lines as $line) {
if ($infos = self::formatNewUser($page, $line, $separator, $hrpromo, 6)) {
$sex = self::formatSex($page, $infos[3], $line);
$lastname = capitalize_name($infos[0]);
$firstname = capitalize_name($infos[1]);
if (!is_null($sex)) {
$fullName = build_full_name($firstname, $lastname);
$directoryName = build_directory_name($firstname, $lastname);
$sortName = build_sort_name($firstname, $lastname);
$birthDate = self::formatBirthDate($infos[2]);
if ($type == 'x') {
if ($promotion < 1996 && preg_match('/^[0-9]{8}$/', $infos[4])) {
/* Allow using Xorg ID for old promotions, to allow fixing typos in names */
$xorgId = $infos[4];
$year = intval(substr($xorgId, 0, 4));
if ($year != $promotion) {
$page->trigError("La ligne {$line} n'a pas été ajoutée car le matricule Xorg n'a pas la date correspondant à la promotion.");
continue;
}
} else {
$xorgId = Profile::getXorgId($infos[4]);
}
} elseif (isset($infos[4])) {
$xorgId = trim($infos[4]);
} else {
$xorgId = 0;
}
if (is_null($xorgId)) {
$page->trigError("La ligne {$line} n'a pas été ajoutée car le matricule École est mal renseigné.");
continue;
}
XDB::execute('INSERT INTO profiles (hrpid, xorg_id, ax_id, birthdate_ref, sex, title)
VALUES ({?}, {?}, {?}, {?}, {?}, {?})', $infos['hrid'], $xorgId, isset($infos[5]) ? $infos[5] : null, $birthDate, $sex, $titles[$sex]);
$pid = XDB::insertId();
XDB::execute('INSERT INTO profile_public_names (pid, lastname_initial, lastname_main, firstname_initial, firstname_main)
VALUES ({?}, {?}, {?}, {?}, {?})', $pid, $lastname, $lastname, $firstname, $firstname);
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, $sortName, $promo);
XDB::execute('INSERT INTO profile_education (id, pid, eduid, degreeid, entry_year, grad_year, promo_year, flags)
VALUES (100, {?}, {?}, {?}, {?}, {?}, {?}, \'primary\')', $pid, $eduSchools[Profile::EDU_X], $degreeid, $entry_year, $grad_year, $promotion);
XDB::execute('INSERT INTO accounts (hruid, type, is_admin, state, full_name, directory_name,
sort_name, display_name, lastname, firstname, sex, best_domain)
VALUES ({?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?})', $infos['hrid'], $type, 0, 'pending', $fullName, $directoryName, $sortName, $firstname, $lastname, $firstname, $sex, $best_domain);
$uid = XDB::insertId();
XDB::execute('INSERT INTO account_profiles (uid, pid, perms)
VALUES ({?}, {?}, {?})', $uid, $pid, 'owner');
Profile::rebuildSearchTokens($pid, false);
}
}
}
XDB::commit();
} else {
if (Env::t('add_type') == 'account') {
//.........这里部分代码省略.........
示例9: commit
public function commit()
{
/* TODO: refines this filter on promotions by using userfilter. */
if (XDB::execute("INSERT INTO announces\n SET uid = {?}, creation_date=NOW(), titre={?}, texte={?},\n expiration={?}, promo_min={?}, promo_max={?}, flags=CONCAT(flags,',valide,wiki')", $this->user->id(), $this->titre, $this->texte, $this->expiration, $this->pmin, $this->pmax)) {
$eid = XDB::insertId();
if ($this->img) {
XDB::execute("INSERT INTO announce_photos\n SET eid = {?}, attachmime = {?}, x = {?}, y = {?}, attach = {?}", XDB::insertId(), $this->imgtype, $this->imgx, $this->imgy, $this->img);
}
global $globals;
if ($globals->banana->event_forum) {
require_once 'banana/forum.inc.php';
$banana = new ForumsBanana($this->user);
$post = $banana->post($globals->banana->event_forum, $globals->banana->event_reply, $this->titre, MiniWiki::wikiToText($this->texte, false, 0, 80));
if ($post != -1) {
XDB::execute("UPDATE announces\n SET creation_date = creation_date, post_id = {?}\n WHERE id = {?}", $post, $eid);
}
}
return true;
}
return false;
}
示例10: commit
public function commit()
{
$res = XDB::query('SELECT id
FROM profile_job_enum
WHERE name = {?}', $this->name);
if ($res->numRows() != 1) {
XDB::execute('INSERT INTO profile_job_enum (name, acronym, url, email, holdingid, SIREN_code, NAF_code, AX_code)
VALUES ({?}, {?}, {?}, {?}, {?}, {?}, {?}, {?})', $this->name, $this->acronym, $this->url, $this->email, $this->holdingid, $this->SIREN, $this->NAF_code, $this->AX_code);
$jobid = XDB::insertId();
$phone = new Phone(array('link_type' => 'hq', 'link_id' => $jobid, 'id' => 0, 'type' => 'fixed', 'display' => $this->tel, 'pub' => 'public'));
$fax = new Phone(array('link_type' => 'hq', 'link_id' => $jobid, 'id' => 1, 'type' => 'fax', 'display' => $this->fax, 'pub' => 'public'));
$address = new Address(array('jobid' => $jobid, 'type' => Address::LINK_COMPANY, 'text' => $this->address));
$phone->save();
$fax->save();
$address->save();
} else {
$jobid = $res->fetchOneCell();
}
XDB::execute('UPDATE profile_job
SET jobid = {?}
WHERE pid = {?} AND id = {?}', $jobid, $this->profile->id(), $this->id);
if (XDB::affectedRows() == 0) {
return XDB::execute('INSERT INTO profile_job (jobid, pid, id)
VALUES ({?}, {?}, {?})', $jobid, $this->profile->id(), $this->id);
}
return true;
}
示例11: insert
public function insert()
{
$schema = Schema::get(get_class($this));
$table = $schema->table();
$id = $schema->id();
XDB::execute("INSERT INTO {$table} SET `{$id}` = NULL");
$this->id = XDB::insertId();
}
示例12: handler_adm_importlogs
function handler_adm_importlogs($page, $step, $param = null)
{
$page->setTitle('Administration - Paiements - Réconciliations');
$page->changeTpl('payment/reconcile.tpl');
$page->assign('step', $step);
if (isset($_SESSION['paymentrecon_data'])) {
// create temporary table with imported data
XDB::execute('CREATE TEMPORARY TABLE payment_tmp (
reference VARCHAR(255) PRIMARY KEY,
date DATE,
amount DECIMAL(9,2),
commission DECIMAL(9,2)
)');
foreach ($_SESSION['paymentrecon_data'] as $i) {
XDB::execute('INSERT INTO payment_tmp VALUES ({?}, {?}, {?}, {?})', $i['reference'], $i['date'], $i['amount'], $i['commission']);
}
}
if ($step == 'step1') {
$page->assign('title', 'Étape 1');
unset($_SESSION['paymentrecon_method']);
unset($_SESSION['paymentrecon_data']);
unset($_SESSION['paymentrecon_id']);
// was a payment method choosen ?
if ($param != null) {
$_SESSION['paymentrecon_method'] = (int) $param;
pl_redirect('admin/reconcile/importlogs/step2');
} else {
// ask to choose a payment method
$res = XDB::query('SELECT id, text FROM payment_methods');
$page->assign('methods', $res->fetchAllAssoc());
}
} elseif ($step == 'step2') {
$page->assign('title', 'Étape 2');
// import logs formated in CVS
$fields = array('date', 'reference', 'amount', 'commission');
$importer = new PaymentLogsImporter();
$importer->apply($page, 'admin/reconcile/importlogs/step2', $fields);
// if import is finished
$result = $importer->get_result();
if ($result != null) {
$_SESSION['paymentrecon_data'] = $result;
pl_redirect('admin/reconcile/importlogs/step3');
}
} elseif ($step == 'step3') {
$page->assign('title', 'Étape 3');
// compute reconcilation summary data
$res = XDB::query('SELECT MIN(date) AS period_start, MAX(date) AS period_end,
count(*) AS payment_count, SUM(amount) AS sum_amounts,
SUM(commission) AS sum_commissions
FROM payment_tmp');
$recon = $res->fetchOneAssoc();
$recon['method_id'] = $_SESSION['paymentrecon_method'];
// create reconciliation item in database
if (Post::has('next')) {
S::assert_xsrf_token();
// get parameters
$recon['period_start'] = preg_replace('/([0-9]{1,2})\\/([0-9]{1,2})\\/([0-9]{4})/', '\\3-\\2-\\1', Post::v('period_start'));
$recon['period_end'] = preg_replace('/([0-9]{1,2})\\/([0-9]{1,2})\\/([0-9]{4})/', '\\3-\\2-\\1', Post::v('period_end'));
// FIXME: save checks to be done at next step
// Create reconcilation item in database
// FIXME: check if period doesn't overlap with others for the same method_id
XDB::execute('INSERT INTO payment_reconcilations (method_id, period_start, period_end,
payment_count, sum_amounts, sum_commissions)
VALUES ({?}, {?}, {?}, {?}, {?}, {?})', $recon['method_id'], $recon['period_start'], $recon['period_end'], $recon['payment_count'], $recon['sum_amounts'], $recon['sum_commissions']);
$_SESSION['paymentrecon_id'] = XDB::insertId();
// reconcile simple cases (trans.commission n'est modifié que s'il vaut NULL)
XDB::execute("UPDATE payment_transactions AS trans, payment_tmp AS tmp\n SET trans.recon_id = {?}, trans.commission=tmp.commission\n WHERE trans.fullref = tmp.reference\n AND trans.amount = tmp.amount AND DATE(trans.ts_confirmed) = tmp.date\n AND (trans.commission IS NULL OR trans.commission = tmp.commission)\n AND method_id = {?} AND recon_id IS NULL AND status = 'confirmed'", $_SESSION['paymentrecon_id'], $recon['method_id']);
pl_redirect("admin/reconcile/importlogs/step4");
// show summary of the imported data + ask form start/end of reconcilation period
} else {
$recon['period_start'] = preg_replace('/([0-9]{4})-([0-9]{2})-([0-9]{2})/', '\\3/\\2/\\1', $recon['period_start']);
$recon['period_end'] = preg_replace('/([0-9]{4})-([0-9]{2})-([0-9]{2})/', '\\3/\\2/\\1', $recon['period_end']);
$page->assign('recon', $recon);
}
} elseif ($step == 'step4') {
$page->assign('title', 'Étape 4');
// get reconcilation summary informations
$res = XDB::query('SELECT * FROM payment_reconcilations WHERE id = {?}', $_SESSION['paymentrecon_id']);
$recon = $res->fetchOneAssoc();
$page->assign('recon', $recon);
if (Post::has('force')) {
S::assert_xsrf_token();
foreach (Post::v('force') as $id => $value) {
XDB::execute('UPDATE payment_transactions AS trans, payment_tmp AS tmp
SET trans.recon_id = {?}, trans.commission = tmp.commission
WHERE trans.id = {?} AND trans.fullref = tmp.reference', $_SESSION['paymentrecon_id'], $id);
}
$page->trigSuccess('La réconciliation a été forcée pour ' . count(Post::v('force')) . ' transaction(s).');
} elseif (Post::has('next')) {
if (strlen($recon['comments']) < 3) {
$page->trigError('Le commentaire doit contenir au moins 3 caractères.');
} else {
XDB::execute("UPDATE payment_reconcilations SET status = 'transfering' WHERE id = {?}", $_SESSION['paymentrecon_id']);
pl_redirect('admin/reconcile/step5');
}
} elseif (Post::has('savecomments')) {
S::assert_xsrf_token();
$recon['comments'] = Post::v('comments');
$page->assign('recon', $recon);
XDB::execute('UPDATE payment_reconcilations SET comments = {?} WHERE id = {?}', $recon['comments'], $_SESSION['paymentrecon_id']);
//.........这里部分代码省略.........
示例13: insert
/**
* Insert a new Wiki in the DB
*/
public function insert()
{
XDB::execute('INSERT INTO wiki SET name = {?}', $this->name);
$this->id = XDB::insertId();
}
示例14: handler_edit
function handler_edit($page, $eid = null)
{
global $globals;
// get eid if the the given one is a short name
if (!is_null($eid) && !is_numeric($eid)) {
$res = XDB::query("SELECT eid\n FROM group_events\n WHERE asso_id = {?} AND short_name = {?}", $globals->asso('id'), $eid);
if ($res->numRows()) {
$eid = (int) $res->fetchOneCell();
}
}
// check the event is in our group
if (!is_null($eid)) {
$res = XDB::query("SELECT short_name\n FROM group_events\n WHERE eid = {?} AND asso_id = {?}", $eid, $globals->asso('id'));
if ($res->numRows()) {
$infos = $res->fetchOneAssoc();
} else {
return PL_FORBIDDEN;
}
}
$page->changeTpl('xnetevents/edit.tpl');
$moments = range(1, 4);
$error = false;
$page->assign('moments', $moments);
if (Post::v('intitule')) {
S::assert_xsrf_token();
$this->load('xnetevents.inc.php');
$short_name = event_change_shortname($page, $eid, $infos['short_name'], Env::v('short_name', ''));
if ($short_name != Env::v('short_name')) {
$error = true;
}
$evt = array('eid' => $eid, 'asso_id' => $globals->asso('id'), 'paiement_id' => Post::v('paiement_id') > 0 ? Post::v('paiement_id') : null, 'debut' => Post::v('deb_Year') . '-' . Post::v('deb_Month') . '-' . Post::v('deb_Day') . ' ' . Post::v('deb_Hour') . ':' . Post::v('deb_Minute') . ':00', 'fin' => Post::v('fin_Year') . '-' . Post::v('fin_Month') . '-' . Post::v('fin_Day') . ' ' . Post::v('fin_Hour') . ':' . Post::v('fin_Minute') . ':00', 'short_name' => $short_name);
$trivial = array('intitule', 'descriptif', 'noinvite', 'subscription_notification', 'show_participants', 'accept_nonmembre', 'uid');
foreach ($trivial as $k) {
$evt[$k] = Post::v($k);
}
if (!$eid) {
$evt['uid'] = S::v('uid');
}
if (Post::v('deadline')) {
$evt['deadline_inscription'] = Post::v('inscr_Year') . '-' . Post::v('inscr_Month') . '-' . Post::v('inscr_Day');
} else {
$evt['deadline_inscription'] = null;
}
// Store the modifications in the database
XDB::execute('INSERT INTO group_events (eid, asso_id, uid, intitule, paiement_id,
descriptif, debut, fin, show_participants,
short_name, deadline_inscription, noinvite,
accept_nonmembre, subscription_notification)
VALUES ({?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?})
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),
accept_nonmembre = VALUES(accept_nonmembre), subscription_notification = VALUES(subscription_notification)', $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['subscription_notification']);
// if new event, get its id
if (!$eid) {
$eid = XDB::insertId();
}
foreach ($moments as $i) {
if (Post::v('titre' . $i)) {
$nb_moments++;
$montant = strtr(Post::v('montant' . $i), ',', '.');
$money_defaut += (double) $montant;
XDB::execute('INSERT INTO group_event_items (eid, item_id, titre, details, montant)
VALUES ({?}, {?}, {?}, {?}, {?})
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);
}
}
// request for a new payment
if (Post::v('paiement_id') == -1 && $money_defaut >= 0) {
$p = new PayReq(S::user(), $globals->asso('nom') . " - " . Post::v('intitule'), Post::v('site'), $money_defaut, Post::v('confirmation'), 0, 999, $globals->asso('id'), $eid, Post::v('payment_public') == 'yes');
if ($p->accept()) {
$p->submit();
} else {
$page->assign('payment_message', Post::v('confirmation'));
$page->assign('payment_site', Post::v('site'));
$page->assign('payment_public', Post::v('payment_public') == 'yes');
$page->assign('error', true);
$error = true;
}
}
// events with no sub-event: add a sub-event with default name
if ($nb_moments == 0) {
XDB::execute("INSERT INTO group_event_items\n VALUES ({?}, {?}, 'Événement', '', 0)", $eid, 1);
}
if (!$error) {
pl_redirect('events');
}
}
// get a list of all the payment for this asso
$res = XDB::iterator("SELECT id, text\n FROM payments\n WHERE asso_id = {?} AND NOT FIND_IN_SET('old', flags)", $globals->asso('id'));
$paiements = array();
while ($a = $res->next()) {
$paiements[$a['id']] = $a['text'];
}
$page->assign('paiements', $paiements);
// when modifying an old event retreive the old datas
//.........这里部分代码省略.........
示例15: createPending
/** Create a new, empty, pending newsletter issue
* @p $nlid The id of the NL for which a new pending issue should be created.
* @return Id of the newly created issue.
*/
public function createPending()
{
XDB::execute('INSERT INTO newsletter_issues
SET nlid = {?}, state=\'new\', date=NOW(),
title=\'to be continued\',
mail_title=\'to be continued\'', $this->id);
return XDB::insertId();
}