本文整理汇总了PHP中DB::GetRow方法的典型用法代码示例。如果您正苦于以下问题:PHP DB::GetRow方法的具体用法?PHP DB::GetRow怎么用?PHP DB::GetRow使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DB
的用法示例。
在下文中一共展示了DB::GetRow方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: is_user_in_group
function is_user_in_group($uid, $group)
{
// $groups_arr = Acl::$gacl->get_object_groups($uid);
$object_id = $uid;
$object_type = 'aro';
$group_table = 'aro_groups';
$map_table = 'groups_aro_map';
$query = 'SELECT gm.group_id FROM ' . $map_table . ' gm ';
$query .= 'WHERE gm.' . $object_type . '_id=' . $object_id;
$rs = DB::Execute($query);
$groups_arr = array();
while ($row = $rs->FetchRow()) {
$groups_arr[] = $row[0];
}
// END
if (!$groups_arr) {
return false;
}
$groups = array();
foreach ($groups_arr as $id) {
//$arr = Acl::$gacl->get_group_data($id);
$group_id = $id;
$group_type = 'aro';
$table = 'aro_groups';
$query = 'SELECT id, parent_id, value, name, lft, rgt FROM ' . $table . ' WHERE id=' . $group_id;
$arr = DB::GetRow($query);
// END
if ($arr[3] == $group) {
return true;
}
}
return false;
}
示例2: DispatchPollUpdateContact
function DispatchPollUpdateContact(PollUpdateContactResponse $resp)
{
if ($resp->IsFailed()) {
Log::Log(sprintf('DispatchPollUpdateContact failed. Registry response: %s', $resp->ErrMsg), E_USER_ERROR);
throw new Exception($resp->ErrMsg, $resp->Code);
}
if ($resp->Succeed()) {
$Contact = $this->DBContact->LoadByCLID($resp->CLID);
try {
// Get remote updated contact
$Contact = $this->GetRemoteContact($Contact);
} catch (NotImplementedException $e) {
// Get updates from local history
$op = $this->DB->GetRow('SELECT * FROM pending_operations WHERE objectid=? AND objecttype=?', array($Contact->ID, self::OBJ_CONTACT));
if (!$op) {
throw new Exception('Pending operation not found');
}
$After = unserialize($op['object_after']);
$fields = array();
foreach ($Contact->GetEditableNames() as $n) {
$fields[$n] = $After->GetField($n);
}
$Contact->SetFieldList($fields);
}
$this->DBContact->Save($Contact);
$this->FireEvent('ContactUpdated', $Contact);
}
}
示例3: send_translation
public static function send_translation($lang, $org, $trans)
{
if (!self::allow_sending()) {
return false;
}
$ip = gethostbyname($_SERVER['SERVER_NAME']);
$r = DB::GetRow('SELECT * FROM base_lang_trans_contrib WHERE user_id=%d', array(Acl::get_user()));
$q = array('first_name' => $r['first_name'], 'last_name' => $r['last_name'], 'lang' => $lang, 'ip' => $ip, 'original' => $org, 'translation' => $trans, 'credits' => $r['credits'], 'credits_website' => $r['credits_website'], 'contact_email' => $r['contact_email']);
$ret = file_get_contents(self::translation_server_url . '/translations.php?' . http_build_query($q));
$success = 'OK;' == $ret;
return $success;
}
示例4: FindByCmd
function FindByCmd($cmd)
{
$this->_db_Init();
$row = DB::GetRow($cmd);
if ($row === null) {
return false;
}
foreach ($this->_db_fields as $prop => $dummy) {
$this->{$prop} = $row[$prop];
}
$this->_db_ProcessAfterFilter();
return true;
}
示例5: get_admin_level
public static function get_admin_level($user = null)
{
if ($user === null) {
$user = self::get_user();
}
$admin = @DB::GetRow('SELECT * FROM user_login WHERE id=%d', array($user));
if ($admin && !empty($admin) && !isset($admin['admin'])) {
return 2;
} else {
$admin = isset($admin['admin']) ? $admin['admin'] : 0;
}
return $admin;
}
示例6: edit_currency
public function edit_currency($id)
{
if ($this->is_back()) {
return false;
}
$form = $this->init_module('Libs_QuickForm');
$form->addElement('header', 'header', __('Edit currency'));
$form->addElement('text', 'code', __('Code'));
$form->addElement('text', 'symbol', __('Symbol'));
$form->addElement('select', 'pos_before', __('Symbol position'), self::$positions);
$form->addElement('text', 'decimal_sign', __('Decimal sign'));
$form->addElement('text', 'thousand_sign', __('Thousand sign'));
$form->addElement('text', 'decimals', __('Decimals'));
$form->addElement('select', 'default_currency', __('Default'), self::$active);
$form->addElement('select', 'active', __('Active'), self::$active);
$form->addRule('code', __('Code must be up to 16 characters long'), 'maxlength', 16);
$form->addRule('symbol', __('Symbol must be up to 8 characters long'), 'maxlength', 8);
$form->addRule('decimal_sign', __('Decimal sign must be up to 2 characters long'), 'maxlength', 2);
$form->addRule('thousand_sign', __('Thousand sign must be up to 2 characters long'), 'maxlength', 2);
$form->addRule('decimals', __('Field must hold numeric value'), 'numeric');
$form->addRule('code', __('Field required'), 'required');
$form->addRule('symbol', __('Field required'), 'required');
$form->addRule('decimal_sign', __('Field required'), 'required');
$form->addRule('decimals', __('Field required'), 'required');
if ($id !== null) {
$defs = DB::GetRow('SELECT * FROM utils_currency WHERE id=%d', array($id));
$form->setDefaults($defs);
if ($defs['default_currency']) {
$form->freeze(array('default_currency'));
}
}
if ($form->validate()) {
$vals = $form->exportValues();
if (isset($vals['default_currency']) && $vals['default_currency']) {
DB::Execute('UPDATE utils_currency SET default_currency=0');
}
$vals = array($vals['code'], $vals['symbol'], $vals['pos_before'], $vals['decimal_sign'], $vals['thousand_sign'], $vals['decimals'], $vals['active'], isset($vals['default_currency']) ? $vals['default_currency'] : 1);
if ($id !== null) {
$vals[] = $id;
$sql = 'UPDATE utils_currency SET ' . 'code=%s, ' . 'symbol=%s, ' . 'pos_before=%d, ' . 'decimal_sign=%s, ' . 'thousand_sign=%s, ' . 'decimals=%d, ' . 'active=%d,' . 'default_currency=%d' . ' WHERE id=%d';
} else {
$sql = 'INSERT INTO utils_currency (' . 'code, ' . 'symbol, ' . 'pos_before, ' . 'decimal_sign, ' . 'thousand_sign, ' . 'decimals, ' . 'active, ' . 'default_currency' . ') VALUES (' . '%s, ' . '%s, ' . '%d, ' . '%s, ' . '%s, ' . '%d, ' . '%d, ' . '%d' . ')';
}
DB::Execute($sql, $vals);
return false;
}
$form->display();
Base_ActionBarCommon::add('back', __('Back'), $this->create_back_href());
Base_ActionBarCommon::add('save', __('Save'), $form->get_submit_form_href());
return true;
}
示例7: meta
public static function meta($id, $use_cache = true)
{
static $meta_cache = array();
if (!is_numeric($id)) {
$id = self::get_storage_id_by_link($id);
}
if ($use_cache && isset($meta_cache[$id])) {
return $meta_cache[$id];
}
$meta = DB::GetRow('SELECT * FROM utils_filestorage_files WHERE id=%d', array($id));
if (!$meta) {
throw new Utils_FileStorage_StorageNotFound('Exception - DB storage object not found: ' . $id);
}
$meta['file'] = self::get_storage_file_path($meta['hash']);
if (!file_exists($meta['file'])) {
throw new Utils_FileStorage_FileNotFound('Exception - file not found: ' . $meta['file']);
}
$meta['links'] = DB::GetCol('SELECT link FROM utils_filestorage_link WHERE storage_id=%d', array($id));
$meta_cache[$id] = $meta;
return $meta;
}
示例8: getOne
public static function getOne($id)
{
$site = $_SESSION['site'];
if (Funcs::$uri[0] == ONESSA_DIR) {
$site = $_SESSION['OneSSA']['site'];
}
$sql = 'SELECT * FROM {{votes}} WHERE id=' . $id . ' AND site=' . $site . '';
$data = DB::GetRow($sql);
$sql = 'SELECT * FROM {{votes}} WHERE parent=' . $id . ' AND site=' . $site . ' ORDER BY num';
$list = DB::GetAll($sql);
$sum = 0;
foreach ($list as $item) {
$sum += $item['answers'];
}
foreach ($list as $i => $item) {
if ($sum != 0) {
$item['width'] = round($item['answers'] / $sum * 100);
} else {
$item['width'] = 0;
}
$data['list'][] = $item;
}
return $data;
}
示例9: Exception
if (!isset($E_SESSION['user'])) {
throw new Exception('Not logged');
}
if (isset($_GET['_autologin_id'])) {
$id = $_GET['_autologin_id'];
setcookie('rc_account', $id);
} elseif (isset($_COOKIE['rc_account'])) {
$id = $_COOKIE['rc_account'];
} else {
throw new Exception('Forbidden');
}
if (!is_numeric($id)) {
throw new Exception('Invalid account id');
}
global $account;
$account = DB::GetRow('SELECT * FROM rc_accounts_data_1 WHERE id=%d AND active=1', array($id));
if ($E_SESSION['user'] !== $account['f_epesi_user']) {
throw new Exception('Access Denied');
}
} catch (Exception $ex) {
header("Cache-Control: private, no-cache, no-store, must-revalidate, post-check=0, pre-check=0");
header("Pragma: no-cache");
header("Expires: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
die($ex->getMessage());
}
/*
+-----------------------------------------------------------------------+
| Local configuration for the Roundcube Webmail installation. |
| |
| This is a sample configuration file only containing the minumum |
示例10: defined
<?php
defined("_VALID_ACCESS") || die('Direct access forbidden');
$mysql = DB::is_mysql();
if ($mysql) {
// remove foregin keys
foreach (array('history', 'session_client') as $tab) {
$a = DB::GetRow("SHOW CREATE TABLE {$tab}");
if (preg_match('/CONSTRAINT (.+) FOREIGN KEY .*session_name/', $a[1], $m)) {
DB::Execute("ALTER TABLE {$tab} DROP FOREIGN KEY " . $m[1]);
}
}
}
PatchUtil::db_alter_column('session', 'name', 'C(128) NOTNULL');
PatchUtil::db_alter_column('session_client', 'session_name', 'C(128) NOTNULL');
PatchUtil::db_alter_column('history', 'session_name', 'C(128) NOTNULL');
if ($mysql) {
DB::Execute('ALTER TABLE history ADD FOREIGN KEY (session_name) REFERENCES session(name)');
DB::Execute('ALTER TABLE session_client ADD FOREIGN KEY (session_name) REFERENCES session(name)');
}
示例11: GetRow
function GetRow()
{
return DB::GetRow($this);
}
示例12: change_node_position
public static function change_node_position($id, $new_pos)
{
DB::StartTrans();
$node = DB::GetRow('SELECT * FROM utils_commondata_tree WHERE id=%d', array($id));
if ($node) {
// move all following nodes back
DB::Execute('UPDATE utils_commondata_tree SET position=position-1 WHERE parent_id=%d AND position>%d', array($node['parent_id'], $node['position']));
// make place for moved node
DB::Execute('UPDATE utils_commondata_tree SET position=position+1 WHERE parent_id=%d AND position>=%d', array($node['parent_id'], $new_pos));
// set new node position
DB::Execute('UPDATE utils_commondata_tree SET position=%d WHERE id=%d', array($new_pos, $id));
}
DB::CompleteTrans();
}
示例13: translations
public function translations()
{
global $translations;
global $custom_translations;
load_js('modules/Base/Lang/Administrator/js/main.js');
eval_js('translate_init();');
$lp = $this->init_module('Utils/LeightboxPrompt');
$form = $this->init_module('Libs/QuickForm', null, 'translations_sending');
$desc = '<div id="trans_sett_info" style="line-height:17px;">';
$desc .= __('You have now option to contribute with your translations to help us deliver EPESI in various languages. You can opt in to send your translations to EPESI central database, allowing to deliver EPESI in your language to other users.') . '<br>';
$desc .= __('Please note that the translations you submit aren\'t subject to copyright. EPESI Team will distribute the translations free of charge to the end users.') . '<br>';
$desc .= __('The only data being sent is the values of the fields presented below and the translated strings, we do not receive any other information contained in EPESI.') . '<br>';
$desc .= __('You can also change your Translations Contribution settings at later time.') . '<br>';
$desc .= '</div>';
eval_js('$("trans_sett_info").up("td").setAttribute("colspan",2);');
eval_js('$("trans_sett_info").up("td").style.borderRadius="0";');
// Not really nice, but will have to do for now
eval_js('$("decription_label").up("td").hide();');
eval_js('function update_credits(){$("contact_email").disabled=$("credits_website").disabled=!$("include_credits").checked||!$("allow").checked;}');
eval_js('update_credits();');
$ip = gethostbyname($_SERVER['SERVER_NAME']);
$me = CRM_ContactsCommon::get_my_record();
$form->addElement('static', 'header', '<div id="decription_label" />', $desc);
$form->addElement('checkbox', 'allow', __('Enable sending translations'), null, array('id' => 'allow', 'onchange' => '$("include_credits").disabled=$("first_name").disabled=$("last_name").disabled=!this.checked;update_credits();'));
$form->addElement('text', 'first_name', __('First Name'), array('id' => 'first_name'));
$form->addElement('text', 'last_name', __('Last Name'), array('id' => 'last_name'));
$form->addElement('checkbox', 'include_credits', __('Include in credits'), null, array('id' => 'include_credits', 'onchange' => 'update_credits();'));
$form->addElement('text', 'credits_website', __('Credits website'), array('id' => 'credits_website'));
$form->addElement('text', 'contact_email', __('Contact e-mail'), array('id' => 'contact_email'));
$form->addElement('static', 'IP', __('IP'), $ip);
$lp->add_option(null, null, null, $form);
eval_js('$("first_name").disabled=$("last_name").disabled=!$("allow").checked;');
$vals = $lp->export_values();
if ($vals) {
$values = $vals['form'];
if (!isset($values['allow'])) {
$values['allow'] = 0;
}
if (!isset($values['first_name'])) {
$values['first_name'] = '';
}
if (!isset($values['last_name'])) {
$values['last_name'] = '';
}
if (!isset($values['include_credits'])) {
$values['include_credits'] = 0;
}
if (!isset($values['credits_website'])) {
$values['credits_website'] = '';
}
if (!isset($values['contact_email'])) {
$values['contact_email'] = '';
}
DB::Execute('DELETE FROM base_lang_trans_contrib WHERE user_id=%d', array(Acl::get_user()));
DB::Execute('INSERT INTO base_lang_trans_contrib (user_id, allow, first_name, last_name, credits, credits_website, contact_email) VALUES (%d, %d, %s, %s, %d, %s, %s)', array(Acl::get_user(), $values['allow'], $values['first_name'], $values['last_name'], $values['include_credits'], $values['credits_website'], $values['contact_email']));
}
$allow_sending = Base_Lang_AdministratorCommon::allow_sending(true);
if ($allow_sending === null || $allow_sending === false) {
$form->setDefaults(array('allow' => 0, 'first_name' => $me['first_name'], 'last_name' => $me['last_name'], 'contact_email' => $me['email']));
} else {
$r = DB::GetRow('SELECT * FROM base_lang_trans_contrib WHERE user_id=%d', array(Acl::get_user()));
if (!$r['first_name']) {
$r['first_name'] = $me['first_name'];
}
if (!$r['last_name']) {
$r['last_name'] = $me['last_name'];
}
if (!$r['contact_email']) {
$r['contact_email'] = $me['email'];
}
$form->setDefaults(array('allow' => $r['allow'], 'first_name' => $r['first_name'], 'last_name' => $r['last_name'], 'contact_email' => $r['contact_email'], 'credits_website' => $r['credits_website'], 'include_credits' => $r['credits']));
}
Base_ActionBarCommon::add('settings', __('Translations Contributions'), $lp->get_href());
$this->display_module($lp, array(__('Translations Contributions settings')));
if (Base_AdminCommon::get_access('Base_Lang_Administrator', 'new_langpack')) {
Base_ActionBarCommon::add('add', __('New langpack'), $this->create_callback_href(array($this, 'new_lang_pack')));
}
if (Base_AdminCommon::get_access('Base_Lang_Administrator', 'select_language')) {
Base_ActionBarCommon::add('refresh', __('Refresh languages'), $this->create_callback_href(array('Base_LangCommon', 'refresh_cache')));
}
$form2 = $this->init_module('Libs/QuickForm', null, 'translaction_filter');
$form2->addElement('select', 'lang_filter', __('Filter'), array(__('Show all'), __('Show with custom translation'), __('Show with translation'), __('Show without translation')), array('onchange' => $form2->get_submit_form_js()));
if ($form2->validate()) {
$vals = $form2->exportValues();
$this->set_module_variable('filter', $vals['lang_filter']);
}
$filter = $this->get_module_variable('filter', 0);
$form2->setDefaults(array('lang_filter' => $filter));
ob_start();
$form2->display_as_row();
$trans_filter = ob_get_clean();
if (!isset($_SESSION['client']['base_lang_administrator']['currently_translating'])) {
$_SESSION['client']['base_lang_administrator']['currently_translating'] = Base_LangCommon::get_lang_code();
}
if (!isset($_SESSION['client']['base_lang_administrator']['notice'])) {
print '<span class="important_notice">' . __('Please make sure the correct language is selected in the box below before you start translating') . ' <a style="float:right;" ' . $this->create_callback_href(array($this, 'hide_notice')) . '>' . __('Discard') . '</a>' . '</span>';
}
if (Base_AdminCommon::get_access('Base_Lang_Administrator', 'translate')) {
$langs = Base_LangCommon::get_installed_langs();
$form = $this->init_module('Libs/QuickForm', null, 'language_selected');
//.........这里部分代码省略.........
示例14: configure_applet
public function configure_applet($id, $mod, &$ok = null)
{
$default_dash = $this->get_module_variable('default');
if (!$default_dash && !Base_DashboardCommon::has_permission_to_manage_applets()) {
return;
}
if ($this->is_back()) {
$ok = false;
return false;
}
$sett_fn = array($mod . 'Common', 'applet_settings');
$is_conf = is_callable($sett_fn);
$fc = $this->get_module_variable('first_conf');
if (!$is_conf && $fc) {
$ok = true;
return false;
}
$f = $this->init_module(Libs_QuickForm::module_name(), __('Saving settings'), 'settings');
$caption = call_user_func(array($mod . 'Common', 'applet_caption'));
if ($is_conf) {
$f->addElement('header', null, __('%s settings', array($caption)));
$menu = call_user_func($sett_fn);
if (is_array($menu)) {
$this->add_module_settings_to_form($menu, $f, $id, $mod);
} else {
trigger_error('Invalid applet settings function: ' . $mod, E_USER_ERROR);
}
}
$f->addElement('header', null, $caption . ' ' . __('display settings'));
$color = Base_DashboardCommon::get_available_colors();
$color[0] = __('Default') . ': ' . $color[0]['label'];
for ($k = 1; $k < count($color); $k++) {
$color[$k] = '• ' . $color[$k]['label'];
}
$f->addElement('select', '__color', __('Color'), $color, array('style' => 'width: 100%;'));
$table_tabs = 'base_dashboard_' . ($default_dash ? 'default_' : '') . 'tabs';
$table_applets = 'base_dashboard_' . ($default_dash ? 'default_' : '') . 'applets';
$tabs = DB::GetAssoc('SELECT id,name FROM ' . $table_tabs . ($default_dash ? '' : ' WHERE user_login_id=' . Base_AclCommon::get_user()));
$f->addElement('select', '__tab', __('Tab'), $tabs);
$dfs = DB::GetRow('SELECT tab,color FROM ' . $table_applets . ' WHERE id=%d', array($id));
$f->setDefaults(array('__tab' => $dfs['tab'], '__color' => $dfs['color']));
if ($f->validate()) {
//$f->process(array(& $this, 'submit_settings'));
$submited = $f->exportValues();
DB::Execute('UPDATE ' . $table_applets . ' SET tab=%d WHERE id=%d', array($submited['__tab'], $id));
DB::Execute('UPDATE ' . $table_applets . ' SET color=%d WHERE id=%d', array($submited['__color'], $id));
$defaults = $this->get_default_values($mod);
$old = $this->get_values($id, $mod);
foreach ($defaults as $name => $def_value) {
if (!isset($submited[$name])) {
$submited[$name] = 0;
}
if ($submited[$name] != $old[$name]) {
if ($this->get_module_variable('default')) {
if ($submited[$name] == $def_value) {
DB::Execute('DELETE FROM base_dashboard_default_settings WHERE applet_id=%d AND name=%s', array($id, $name));
} else {
DB::Replace('base_dashboard_default_settings', array('applet_id' => $id, 'name' => $name, 'value' => $submited[$name]), array('applet_id', 'name'), true);
}
} else {
if ($submited[$name] == $def_value) {
DB::Execute('DELETE FROM base_dashboard_settings WHERE applet_id=%d AND name=%s', array($id, $name));
} else {
DB::Replace('base_dashboard_settings', array('applet_id' => $id, 'name' => $name, 'value' => $submited[$name]), array('applet_id', 'name'), true);
}
}
}
}
$ok = true;
self::$settings_cache = null;
return false;
}
$ok = null;
$f->display();
Base_ActionBarCommon::add('back', __('Back'), $this->create_back_href());
Base_ActionBarCommon::add('save', __('Save'), $f->get_submit_form_href());
Base_ActionBarCommon::add('settings', __('Restore Defaults'), 'onClick="' . $this->set_default_js . '" href="javascript:void(0)"');
return true;
}
示例15: die
* @subpackage attachment
*/
if (!isset($_REQUEST['cid']) || !isset($_REQUEST['id'])) {
die('Invalid usage');
}
$cid = $_REQUEST['cid'];
$id = $_REQUEST['id'];
$disposition = isset($_REQUEST['view']) && $_REQUEST['view'] ? 'inline' : 'attachment';
define('CID', $cid);
define('READ_ONLY_SESSION', true);
require_once '../../../include.php';
ModuleManager::load_modules();
if (!Acl::is_user()) {
die('Permission denied');
}
$file = DB::GetRow('SELECT uaf.attach_id, uaf.original, uaf.filestorage_id FROM utils_attachment_file uaf WHERE uaf.id=%d', array($id));
$rec = Utils_RecordBrowserCommon::get_record('utils_attachment', $file['attach_id']);
if (!$rec) {
die('Invalid attachment.');
}
$access_fields = Utils_RecordBrowserCommon::get_access('utils_attachment', 'view', $rec);
if (!isset($access_fields['note']) || !$access_fields['note']) {
die('Access forbidden');
}
$original = $file['original'];
$local = $rec['id'];
$fsid = $file['filestorage_id'];
$crypted = $rec['crypted'];
$meta = Utils_FileStorageCommon::meta($fsid);
require_once 'mime.php';
if (headers_sent()) {