本文整理汇总了PHP中XDB::query方法的典型用法代码示例。如果您正苦于以下问题:PHP XDB::query方法的具体用法?PHP XDB::query怎么用?PHP XDB::query使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XDB
的用法示例。
在下文中一共展示了XDB::query方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: update_membernum
public function update_membernum($fid, $num = 1)
{
if (!intval($fid) || !intval($num)) {
return false;
}
XDB::query("UPDATE %t SET membernum=membernum+%d WHERE fid=%d", array('forum_forumfield', $num, $fid));
}
示例2: IsCandidate
public static function IsCandidate(User $user, $candidate)
{
$profile = $user->profile();
if (!$profile) {
return false;
}
// We only test if the user is in her promotion group for it is too
// expensive to check if she is in the corresponding ML as well.
$res = XDB::query('SELECT COUNT(*)
FROM group_members
WHERE uid = {?} AND asso_id = (SELECT id
FROM groups
WHERE diminutif = {?})', $user->id(), $user->profile()->yearPromo());
$mlCount = $res->fetchOneCell();
if ($mlCount) {
Reminder::MarkCandidateAsAccepted($user->id(), $candidate);
}
if ($mlCount == 0) {
$mlist = MailingList::promo($user->profile()->yearPromo());
try {
$mlist->getMembersLimit(0, 0);
} catch (Exception $e) {
return false;
}
}
return false;
}
示例3: prepareform
function prepareform($pay, $user)
{
// Documentation:
// https://www.paypal.com/developer
// Warning: the automatic return only works if we force the
// users to create a paypal account. We do not use it; thus
// the user must come back on the site.
global $globals, $platal;
$this->urlform = 'https://' . $globals->money->paypal_site . '/cgi-bin/webscr';
$roboturl = str_replace("https://", "http://", $globals->baseurl) . '/' . $platal->ns . "payment/paypal_return/" . $user->id() . "?comment=" . urlencode(Env::v('comment')) . '&display=' . Post::i('display');
$this->infos = array('commercant' => array('business' => $globals->money->paypal_compte, 'rm' => 2, 'return' => $roboturl, 'cn' => 'Commentaires', 'no_shipping' => 1, 'cbt' => empty($GLOBALS['IS_XNET_SITE']) ? 'Revenir sur polytechnique.org.' : 'Revenir sur polytechnique.net.'));
$info_client = array('first_name' => $user->firstName(), 'last_name' => $user->lastName(), 'email' => $user->bestEmail());
if ($user->hasProfile()) {
$res = XDB::query("SELECT pa.text, GROUP_CONCAT(pace2.short_name) AS city,\n GROUP_CONCAT(pace3.short_name) AS zip, GROUP_CONCAT(pace1.short_name) AS country,\n IF(pp1.display_tel != '', pp1.display_tel, pp2.display_tel) AS night_phone_b\n FROM profile_addresses AS pa\n LEFT JOIN profile_phones AS pp1 ON (pp1.pid = pa.pid AND pp1.link_type = 'address' AND pp1.link_id = pa.id)\n LEFT JOIN profile_phones AS pp2 ON (pp2.pid = pa.pid AND pp2.link_type = 'user' AND pp2.link_id = 0)\n LEFT JOIN profile_addresses_components AS pc ON (pa.pid = pc.pid AND pa.jobid = pc.jobid AND pa.groupid = pc.groupid\n AND pa.type = pc.type AND pa.id = pc.id)\n LEFT JOIN profile_addresses_components_enum AS pace1 ON (FIND_IN_SET('country', pace1.types) AND pace1.id = pc.component_id)\n LEFT JOIN profile_addresses_components_enum AS pace2 ON (FIND_IN_SET('locality', pace2.types) AND pace2.id = pc.component_id)\n LEFT JOIN profile_addresses_components_enum AS pace3 ON (FIND_IN_SET('postal_code', pace3.types) AND pace3.id = pc.component_id)\n WHERE pa.pid = {?} AND FIND_IN_SET('current', pa.flags)\n GROUP BY pa.pid, pa.jobid, pa.groupid, pa.id, pa.type\n LIMIT 1", $user->profile()->id());
if (is_array($res)) {
$this->infos['client'] = array_map('replace_accent', array_merge($info_client, $res->fetchOneAssoc()));
list($this->infos['client']['address1'], $this->infos['client']['address2']) = explode("\n", Geocoder::getFirstLines($this->infos['client']['text'], $this->infos['client']['zip'], 2));
unset($this->infos['client']['text']);
} else {
$this->infos['client'] = array_map('replace_accent', $info_client);
}
} else {
$this->infos['client'] = array_map('replace_accent', $info_client);
}
// We build the transaction's reference
$prefix = rand_url_id();
$fullref = substr("{$prefix}-xorg-{$pay->id}", -15);
$this->infos['commande'] = array('item_name' => replace_accent($pay->text), 'amount' => $this->val_number, 'currency_code' => 'EUR', 'custom' => $fullref);
$this->infos['divers'] = array('cmd' => '_xclick');
}
示例4: run
public function run()
{
global $platal, $globals;
$nom = S::v('prenom') . ' ' . S::v('nom');
$mail = $this->user->bestEmail();
$sig = $nom . ' (' . S::v('promo') . ')';
Banana::$msgedit_headers['X-Org-Mail'] = $this->user->forlifeEmail();
// Tree color
$req = XDB::query('SELECT tree_unread, tree_read
FROM forum_profiles
WHERE uid= {?}', $this->user->id());
if (!(list($unread, $read) = $req->fetchOneRow())) {
$unread = 'o';
$read = 'dg';
}
Banana::$tree_unread = $unread;
Banana::$tree_read = $read;
// Build user profile
Banana::$profile['headers']['From'] = "{$nom} <{$mail}>";
Banana::$profile['headers']['Organization'] = make_Organization();
Banana::$profile['signature'] = $sig;
// Page design
Banana::$page->killPage('forums');
Banana::$page->killPage('subscribe');
// Run Banana
return parent::run();
}
示例5: _fetchData
protected function _fetchData()
{
$res = XDB::query('SELECT message
FROM profile_deltaten
WHERE pid = {?}', $this->pid());
$this->values['message'] = $res->fetchOneCell();
}
示例6: run
public function run()
{
$today = date('d');
$month = date('m');
$res = XDB::query("\n SELECT name\n FROM days\n WHERE day={$today} AND month={$month}\n ");
$fetes = $res->fetchColumn(0);
$this->assign("fetes", $fetes);
}
示例7: checkOrphanedSessions
/**
* Checks for sessions without a valid associated user id.
*/
function checkOrphanedSessions()
{
$begin = time();
$res = XDB::query("SELECT COUNT(*)\n FROM log_sessions AS s\n LEFT JOIN #x5dat#.accounts AS a ON (a.uid = s.uid)\n WHERE a.uid IS NULL");
if ($count = $res->fetchOneCell()) {
$duration = time() - $begin;
echo "Orphaned sessions: found {$count} orphaned sessions in {$duration} seconds. Please fix that.\n";
}
}
示例8: value
public function value(ProfilePage $page, $field, $value, &$success)
{
$success = true;
if (is_null($value)) {
$res = XDB::query("SELECT section\n FROM profiles\n WHERE pid = {?}", $page->pid());
return intval($res->fetchOneCell());
}
return intval($value);
}
示例9: get_address_text
function get_address_text($adr)
{
$t = '';
if (isset($adr['adr1']) && $adr['adr1']) {
$t .= $adr['adr1'];
}
if (isset($adr['adr2']) && $adr['adr2']) {
$t .= "\n" . $adr['adr2'];
}
if (isset($adr['adr3']) && $adr['adr3']) {
$t .= "\n" . $adr['adr3'];
}
$l = '';
if (isset($adr['display']) && $adr['display']) {
$keys = explode(' ', $adr['display']);
foreach ($keys as $key) {
if (isset($adr[$key])) {
$l .= ' ' . $adr[$key];
} else {
$l .= ' ' . $key;
}
}
if ($l) {
substr($l, 1);
}
} elseif ($adr['country'] == 'US' || $adr['country'] == 'CA' || $adr['country'] == 'GB') {
if ($adr['city']) {
$l .= $adr['city'] . ",\n";
}
if ($adr['region']) {
$l .= $adr['region'] . ' ';
}
if ($adr['postcode']) {
$l .= $adr['postcode'];
}
} else {
if (isset($adr['postcode']) && $adr['postcode']) {
$l .= $adr['postcode'] . ' ';
}
if (isset($adr['city']) && $adr['city']) {
$l .= $adr['city'];
}
}
if ($l) {
$t .= "\n" . trim($l);
}
if ($adr['country'] != '00' && (!$adr['countrytxt'] || $adr['countrytxt'] == strtoupper($adr['countrytxt']))) {
$res = XDB::query('SELECT countryFR
FROM geoloc_countries
WHERE iso_3166_1_a2 = {?}', $adr['country']);
$adr['countrytxt'] = $res->fetchOneCell();
}
if (isset($adr['countrytxt']) && $adr['countrytxt']) {
$t .= "\n" . $adr['countrytxt'];
}
return trim($t);
}
示例10: __construct
public function __construct(User $_user, Profile $_profile, $_newGradYear)
{
parent::__construct($_user, $_profile, true, 'orange');
$this->newGradYear = $_newGradYear;
$res = XDB::query("SELECT entry_year, grad_year\n FROM profile_education\n WHERE pid = {?} AND FIND_IN_SET('primary', flags)", $this->profile->id());
$years = $res->fetchOneRow();
$this->entryYear = $years[0];
$this->oldGradYear = $years[1];
}
示例11: IsCandidate
public static function IsCandidate(User $user, $candidate)
{
$res = XDB::query("SELECT COUNT(*) AS lists\n FROM register_subs\n WHERE uid = {?} AND type = 'list'", $user->id());
$mlCount = $res->fetchOneCell();
if (!$mlCount) {
Reminder::MarkCandidateAsAccepted($user->id(), $candidate);
}
return $mlCount > 0;
}
示例12: update_num_by_catid
public function update_num_by_catid($num, $catid, $numlimit = false)
{
$args = array($this->_table, $num, $catid);
if ($numlimit !== false) {
$sql = ' AND num>0';
$args[] = $numlimit;
}
return XDB::query("UPDATE %t SET num=num+'%d' WHERE catid=%d {$sql}", $args);
}
示例13: run
public function run()
{
$res = XDB::query('SELECT todo_id, sent, checked, tobedone
FROM todo
WHERE uid = {?}
ORDER BY sent DESC', S::user()->id());
$array_todo = $res->fetchAllAssoc();
$this->assign('list', $array_todo);
}
示例14: formu
public function formu()
{
$res = XDB::query('SELECT IF(MAX(m.last)>p.relance, MAX(m.last), p.relance)
FROM accounts AS a
LEFT JOIN register_pending AS p ON p.uid = a.uid
LEFT JOIN register_marketing AS m ON m.uid = a.uid
WHERE a.uid = {?}', $this->m_user->id());
$this->m_relance = $res->fetchOneCell();
return 'include/form.valid.mark.tpl';
}
示例15: update_all
public function update_all($data)
{
if (is_array($data)) {
$update = array();
foreach ($data as $key => $val) {
$update[] = "`" . $key . "` = '" . $val . "'";
}
$setwhere = implode($update, ', ');
XDB::query("UPDATE " . XDB::table($this->_table) . " SET " . $setwhere);
}
}