本文整理汇总了PHP中DBQuery::fetchRow方法的典型用法代码示例。如果您正苦于以下问题:PHP DBQuery::fetchRow方法的具体用法?PHP DBQuery::fetchRow怎么用?PHP DBQuery::fetchRow使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DBQuery
的用法示例。
在下文中一共展示了DBQuery::fetchRow方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getAllUsersGroupByDept
function getAllUsersGroupByDept()
{
$q = new DBQuery();
$q->addTable('users');
$q->addQuery('user_id, contact_department, concat_ws(", ", contact_last_name, contact_first_name) as contact_name');
$q->addJoin('contacts', 'con', 'contact_id = user_contact');
$q->addOrder('contact_last_name');
$res = $q->exec();
$userlist = array();
while ($row = $q->fetchRow()) {
if ($row['contact_department'] == null) {
$row['contact_department'] = 0;
}
if (!isset($userlist[$row['contact_department']])) {
$userlist[$row['contact_department']] = array();
}
$userlist[$row['contact_department']][$row['user_id']] = $row['contact_name'];
}
$q->clear();
return $userlist;
}
示例2: dPgetSysVal
function dPgetSysVal($title)
{
$q = new DBQuery();
$q->addTable('sysvals');
$q->leftJoin('syskeys', 'sk', 'syskey_id = sysval_key_id');
$q->addQuery('syskey_type, syskey_sep1, syskey_sep2, sysval_value');
$q->addWhere("sysval_title = '{$title}'");
$q->exec();
$row = $q->fetchRow();
$q->clear();
// type 0 = list
$sep1 = $row['syskey_sep1'];
// item separator
$sep2 = $row['syskey_sep2'];
// alias separator
// A bit of magic to handle newlines and returns as separators
// Missing sep1 is treated as a newline.
if (!isset($sep1) || empty($sep1)) {
$sep1 = "\n";
}
if ($sep1 == "\\n") {
$sep1 = "\n";
}
if ($sep1 == "\\r") {
$sep1 = "\r";
}
$temp = explode($sep1, $row['sysval_value']);
$arr = array();
// We use trim() to make sure a numeric that has spaces
// is properly treated as a numeric
foreach ($temp as $item) {
if ($item) {
$sep2 = empty($sep2) ? "\n" : $sep2;
$temp2 = explode($sep2, $item);
if (isset($temp2[1])) {
$arr[trim($temp2[0])] = trim($temp2[1]);
} else {
$arr[trim($temp2[0])] = trim($temp2[0]);
}
}
}
return $arr;
}
示例3: DBQuery
if ($_POST['out_session'] && $_POST['out_user_log_id']) {
$boot_user_session = $_POST['out_session'];
$boot_user_log_id = $_POST['out_user_log_id'];
$boot_query_row = false;
} else {
if ($canEdit && $canDelete && $logoutUserFlag) {
// query for all sessions open for a given user
$r = new DBQuery();
$r->addTable('sessions', 's');
$r->addQuery('DISTINCT(session_id), user_access_log_id');
$r->addJoin('user_access_log', 'ual', 'session_user = user_access_log_id');
$r->addWhere('user_id = ' . $boot_user_id);
$r->addOrder('user_access_log_id');
//execute query and fetch results
$r->exec();
$boot_query_row = $r->fetchRow();
if ($boot_query_row) {
$boot_user_session = $boot_query_row['session_id'];
$boot_user_log_id = $boot_query_row['user_access_log_id'];
}
}
}
do {
if ($boot_user_id == $AppUI->user_id && $boot_user_session == $_COOKIE['PHPSESSID']) {
$AppUI->resetPlace();
$AppUI->redirect('logout=-1');
} else {
addHistory('login', $boot_user_id, 'logout', $details);
dPsessionDestroy($boot_user_session, $boot_user_log_id);
}
if ($boot_query_row) {
示例4: store
function store()
{
global $db;
if (!is_array($this->options)) {
$this->options = array();
}
//load the dbs options and compare them with the options
$q = new DBQuery();
$q->addTable('custom_fields_lists');
$q->addWhere('field_id = ' . $this->field_id);
$q->addOrder('list_value');
if (!($rs = $q->exec())) {
$q->clear();
return $db->ErrorMsg();
}
$dboptions = array();
while ($opt_row = $q->fetchRow()) {
$dboptions[$opt_row['list_option_id']] = $opt_row['list_value'];
}
$q->clear();
$newoptions = array();
$newoptions = array_diff($this->options, $dboptions);
$deleteoptions = array_diff($dboptions, $this->options);
//insert the new options
foreach ($newoptions as $opt) {
$optid = $db->GenID('custom_fields_option_id', 1);
$q = new DBQuery();
$q->addTable('custom_fields_lists');
$q->addInsert('field_id', $this->field_id);
$q->addInsert('list_option_id', $optid);
$q->addInsert('list_value', db_escape($opt));
if (!$q->exec()) {
$insert_error = $db->ErrorMsg();
}
$q->clear();
}
//delete the deleted options
foreach ($deleteoptions as $opt => $value) {
$q = new DBQuery();
$q->setDelete('custom_fields_lists');
$q->addWhere('list_option_id = ' . $opt);
if (!$q->exec()) {
$delete_error = $db->ErrorMsg();
}
$q->clear();
}
return $insert_error . ' ' . $delete_error;
}
示例5: sendWatchMail
public function sendWatchMail($debug = false)
{
global $AppUI, $debug, $w2Pconfig;
$subj_prefix = $AppUI->_('forumEmailSubj', UI_OUTPUT_RAW);
$body_msg = $AppUI->_('forumEmailBody', UI_OUTPUT_RAW);
// Get the message from details.
$q = new DBQuery();
$q->addTable('users', 'u');
$q->addQuery('contact_email, contact_first_name, contact_last_name');
$q->addJoin('contacts', 'con', 'contact_id = user_contact', 'inner');
$q->addWhere('user_id = ' . (int) $this->message_author);
$res = $q->exec();
if ($row = $q->fetchRow()) {
$message_from = $row['contact_first_name'] . ' ' . $row['contact_last_name'] . '<' . $row['contact_email'] . '>';
} else {
$message_from = 'Unknown user';
}
// Get the forum name;
$q->clear();
$q->addTable('forums');
$q->addQuery('forum_name');
$q->addWhere('forum_id = \'' . $this->message_forum . '\'');
$res = $q->exec();
if ($row = $q->fetchRow()) {
$forum_name = $row['forum_name'];
} else {
$forum_name = 'Unknown';
}
// SQL-Query to check if the message should be delivered to all users (forced)
// In positive case there will be a (0,0,0) row in the forum_watch table
$q->clear();
$q->addTable('forum_watch');
$q->addQuery('*');
$q->addWhere('watch_user = 0 AND watch_forum = 0 AND watch_topic = 0');
$resAll = $q->exec();
$AllCount = db_num_rows($resAll);
$q->clear();
$q->addTable('users');
$q->addQuery('DISTINCT contact_email, user_id, contact_first_name, contact_last_name');
$q->leftJoin('contacts', 'con', 'contact_id = user_contact');
if ($AllCount < 1) {
//message is only delivered to users that checked the forum watch
$q->addTable('forum_watch');
$q->addWhere('user_id = watch_user AND (watch_forum = ' . (int) $this->message_forum . ' OR watch_topic = ' . (int) $this->message_parent . ')');
}
if (!($res = $q->exec(ADODB_FETCH_ASSOC))) {
$q->clear();
return;
}
if (db_num_rows($res) < 1) {
return;
}
$mail = new Mail();
$mail->Subject($subj_prefix . ' ' . $this->message_title, isset($GLOBALS['locale_char_set']) ? $GLOBALS['locale_char_set'] : '');
$body = $body_msg;
$body .= "\n\n" . $AppUI->_('Forum', UI_OUTPUT_RAW) . ': ' . $forum_name;
$body .= "\n" . $AppUI->_('Subject', UI_OUTPUT_RAW) . ': ' . $this->message_title;
$body .= "\n" . $AppUI->_('Message From', UI_OUTPUT_RAW) . ': ' . $message_from;
$body .= "\n\n" . W2P_BASE_URL . '/index.php?m=forums&a=viewer&forum_id=' . $this->message_forum;
$body .= "\n\n" . $this->message_body;
$mail->Body($body, isset($GLOBALS['locale_char_set']) ? $GLOBALS['locale_char_set'] : '');
while ($row = $q->fetchRow()) {
if ($mail->ValidEmail($row['contact_email'])) {
$mail->To($row['contact_email'], true);
$mail->Send();
}
}
$q->clear();
return;
}
示例6: remind
/**
* Called by the Event Queue processor to process a reminder
* on a task.
* @access public
* @param string $module Module name (not used)
* @param string $type Type of event (not used)
* @param integer $id ID of task being reminded
* @param integer $owner Originator of event
* @param mixed $args event-specific arguments.
* @return mixed true, dequeue event, false, event stays in queue.
-1, event is destroyed.
*/
function remind($module, $type, $id, $owner, &$args)
{
global $locale_char_set, $AppUI;
$q = new DBQuery();
$df = $AppUI->getPref('SHDATEFORMAT');
$tf = $AppUI->getPref('TIMEFORMAT');
// If we don't have preferences set for these, use ISO defaults.
if (!$df) {
$df = '%Y-%m-%d';
}
if (!$tf) {
$tf = '%H:%m';
}
$df .= ' ' . $tf;
// At this stage we won't have an object yet
if (!$this->load($id)) {
return -1;
// No point it trying again later.
}
$this->htmlDecode();
// Only remind on working days.
$today = new CDate();
if (!$today->isWorkingDay()) {
return true;
}
// Check if the task is completed
if ($this->task_percent_complete == 100) {
return -1;
}
// Grab the assignee list
$q->addTable('user_tasks', 'ut');
$q->leftJoin('users', 'u', 'u.user_id = ut.user_id');
$q->leftJoin('contacts', 'c', 'c.contact_id = u.user_contact');
$q->addQuery('c.contact_id, contact_first_name, contact_last_name, contact_email');
$q->addWhere('ut.task_id = ' . $id);
$contacts = $q->loadHashList('contact_id');
$q->clear();
// Now we also check the owner of the task, as we will need
// to notify them as well.
$owner_is_not_assignee = false;
$q->addTable('users', 'u');
$q->leftJoin('contacts', 'c', 'c.contact_id = u.user_contact');
$q->addQuery('c.contact_id, contact_first_name, contact_last_name, contact_email');
$q->addWhere('u.user_id = ' . $this->task_owner);
if ($q->exec(ADODB_FETCH_NUM)) {
list($owner_contact, $owner_first_name, $owner_last_name, $owner_email) = $q->fetchRow();
if (!isset($contacts[$owner_contact])) {
$owner_is_not_assignee = true;
$contacts[$owner_contact] = array('contact_id' => $owner_contact, 'contact_first_name' => $owner_first_name, 'contact_last_name' => $owner_last_name, 'contact_email' => $owner_email);
}
}
$q->clear();
// build the subject line, based on how soon the
// task will be overdue.
$starts = new CDate($this->task_start_date);
$expires = new CDate($this->task_end_date);
$now = new CDate();
$diff = $expires->dateDiff($now);
$prefix = $AppUI->_('Task Due', UI_OUTPUT_RAW);
if ($diff == 0) {
$msg = $AppUI->_('TODAY', UI_OUTPUT_RAW);
} else {
if ($diff == 1) {
$msg = $AppUI->_('TOMORROW', UI_OUTPUT_RAW);
} else {
if ($diff < 0) {
$msg = $AppUI->_(array('OVERDUE', abs($diff), 'DAYS'));
$prefix = $AppUI->_('Task', UI_OUTPUT_RAW);
} else {
$msg = $AppUI->_(array($diff, 'DAYS'));
}
}
}
$q->addTable('projects');
$q->addQuery('project_name');
$q->addWhere('project_id = ' . $this->task_project);
$project_name = htmlspecialchars_decode($q->loadResult());
$q->clear();
$subject = $prefix . ' ' . $msg . ' ' . $this->task_name . '::' . $project_name;
$body = $AppUI->_('Task Due', UI_OUTPUT_RAW) . ': ' . $msg . "\n" . $AppUI->_('Project', UI_OUTPUT_RAW) . ': ' . $project_name . "\n" . $AppUI->_('Task', UI_OUTPUT_RAW) . ': ' . $this->task_name . "\n" . $AppUI->_('Start Date', UI_OUTPUT_RAW) . ': ' . $starts->format($df) . "\n" . $AppUI->_('Finish Date', UI_OUTPUT_RAW) . ': ' . $expires->format($df) . "\n" . $AppUI->_('URL', UI_OUTPUT_RAW) . ': ' . DP_BASE_URL . '/index.php?m=tasks&a=view&task_id=' . $this->task_id . '&reminded=1' . "\n\n" . $AppUI->_('Resources', UI_OUTPUT_RAW) . ":\n";
foreach ($contacts as $contact) {
if ($owner_is_not_assignee || $contact['contact_id'] != $owner_contact) {
$body .= $contact['contact_first_name'] . ' ' . $contact['contact_last_name'] . ' <' . $contact['contact_email'] . ">\n";
}
}
$body .= "\n" . $AppUI->_('Description', UI_OUTPUT_RAW) . ":\n" . $this->task_description . "\n";
$mail = new Mail();
foreach ($contacts as $contact) {
//.........这里部分代码省略.........
示例7: array
$q2->addWhere($where_list);
}
if ($project_id > 0) {
$q2->addWhere('project_id = ' . $project_id);
}
$q2->addGroup('project_id');
$perms =& $AppUI->acl();
$projects = array();
$canViewTask = $perms->checkModule('tasks', 'view');
if ($canViewTask) {
$prc = $q->exec();
echo db_error();
while ($row = $q->fetchRow()) {
$projects[$row['project_id']] = $row;
}
$prc2 = $q2->fetchRow();
echo db_error();
while ($row2 = $q2->fetchRow()) {
if ($projects[$row2['project_id']]) {
array_push($projects[$row2['project_id']], $row2);
}
}
}
$q->clear();
$q2->clear();
$q->addQuery('tasks.task_id, task_parent, task_name');
$q->addQuery('task_start_date, task_end_date, task_dynamic');
$q->addQuery('task_pinned, pin.user_id as pin_user');
$q->addQuery('task_priority, task_percent_complete');
$q->addQuery('task_duration, task_duration_type');
$q->addQuery('task_project');
示例8: db_error
$df = $AppUI->getPref('SHDATEFORMAT');
$tf = $AppUI->getPref('TIMEFORMAT');
$q = new DBQuery();
$q->addTable('forums');
$q->addTable('projects', 'p');
$q->addTable('users', 'u');
$q->addQuery('forum_id, forum_project, forum_description, forum_owner, forum_name,
forum_create_date, forum_last_date, forum_message_count, forum_moderated,
user_username, contact_first_name, contact_last_name,
project_name, project_color_identifier');
$q->addJoin('contacts', 'con', 'contact_id = user_contact');
$q->addWhere("user_id = forum_owner");
$q->addWhere("forum_id = {$forum_id}");
$q->addWhere("forum_project = project_id");
$q->exec(ADODB_FETCH_ASSOC);
$forum = $q->fetchRow();
$forum_name = $forum["forum_name"];
echo db_error();
$q->clear();
$start_date = intval($forum["forum_create_date"]) ? new CDate($forum["forum_create_date"]) : null;
//20090907 KSen@Itsutsubashi
$project_id = $forum['forum_project'];
// setup the title block
$titleBlock = new CTitleBlock('Forum', 'support.png', $m, "{$m}.{$a}");
$titleBlock->addCell(arraySelect($filters, 'f', 'size="1" class="text" onchange="document.filterFrm.submit();"', $f, true), '', '<form action="?m=forums&a=viewer&forum_id=' . $forum_id . '" method="post" name="filterFrm">', '</form>');
$titleBlock->show();
?>
<table width="100%" cellspacing="0" cellpadding="2" border="0" class="std">
<tr>
<td height="20" colspan="3" style="border: outset #D1D1CD 1px;background-color:#<?php
echo $forum["project_color_identifier"];
示例9: array
$projTasks = array();
$task_parent_options = '';
// Now lets get non-root tasks, grouped by the task parent
$q = new DBQuery();
$q->addTable('tasks');
$q->addQuery('task_id, task_name, task_end_date, task_start_date, task_milestone, task_parent, task_dynamic');
$q->addWhere('task_project = ' . (int) $task_project);
$q->addWhere('task_id <> task_parent');
$q->addOrder('task_start_date');
$parents = array();
$projTasksWithEndDates = array($task->task_id => $AppUI->_('None'));
//arrays contains task end date info for setting new task start date as maximum end date of dependenced tasks
$all_tasks = array();
$sub_tasks = $q->exec();
if ($sub_tasks) {
while ($sub_task = $q->fetchRow()) {
// Build parent/child task list
$parents[$sub_task['task_parent']][] = $sub_task['task_id'];
$all_tasks[$sub_task['task_id']] = $sub_task;
build_date_list($projTasksWithEndDates, $sub_task);
}
}
$q->clear();
// let's iterate root tasks
foreach ($root_tasks as $root_task) {
build_date_list($projTasksWithEndDates, $root_task);
if ($root_task['task_id'] != $task_id) {
constructTaskTree($root_task);
}
}
// setup the title block
示例10: show_history
function show_history($history)
{
global $AppUI;
$id = $history['history_item'];
$table = $history['history_table'];
$q = new DBQuery();
$q->addTable('modules', 'm');
$q->addQuery('m.*');
$q->addWhere("m.`permissions_item_table` LIKE '" . $table . "'");
$q - exec();
$module_result = $q->fetchRow();
$q->clear();
$table_id = $module_result['permissions_item_field'];
$module = $module_result['mod_directory'];
if (!($table_id || $module)) {
//valid "modules" w/o item level permissions
switch ($table) {
case 'history':
//table name does not match with module name
$table_id = 'history_id';
$module = 'history';
break;
}
}
if ($table == 'login') {
return $AppUI->_('User') . ' \'' . $history['history_description'] . '\' ' . $AppUI->_($history['history_action']);
}
if ($history['history_action'] == 'add') {
$msg = $AppUI->_('Added new') . ' ';
} else {
if ($history['history_action'] == 'update') {
$msg = $AppUI->_('Modified') . ' ';
} else {
if ($history['history_action'] == 'delete') {
return $AppUI->_('Deleted') . ' \'' . $history['history_description'] . '\' ' . $AppUI->_('from') . ' ' . $AppUI->_($table) . ' ' . $AppUI->_('table');
}
}
}
if ($table_id && $module) {
$q->addTable($table);
$q->addQuery($table_id);
$q->addWhere($table_id . '=' . $id);
$is_table_result = $q->loadResult();
$q->clear();
}
if ($is_table_result) {
switch ($table) {
case 'history':
case 'files':
case 'links':
$link = '&a=addedit&' . $table_id . '=';
break;
case 'tasks':
case 'projects':
case 'companies':
case 'departments':
case 'events':
case 'contacts':
$link = '&a=view&' . $table_id . '=';
break;
case 'forums':
$link = '&a=viewer&' . $table_id . '=';
break;
case 'task_log':
$module = 'tasks';
$q->addTable('task_log');
$q->addQuery('task_log_task');
$q->addWhere('task_log_id = ' . $id);
$task_log_task = $q->loadResult();
$q->clear();
$link = '&a=view&task_id=' . $task_log_task . '&tab=1&' . $table_id . '=';
$in_page_anchor = '#log';
break;
}
}
$link = !empty($link) ? '<a href="?m=' . $module . $link . $id . $in_page_anchor . '">' . stripslashes($history['history_description']) . '</a>' : stripslashes($history['history_description']);
$msg .= $AppUI->_('item') . ' "' . $link . '" ' . $AppUI->_('in') . ' "' . $AppUI->_($table) . '" ' . $AppUI->_('table');
return $msg;
}
示例11: db_error
$canEdit = $perms->checkModuleItem('forums', 'edit', $forum_id);
// check permissions
if (!$canAuthor && !$forum_id) {
$AppUI->redirect('m=public&a=access_denied');
}
if (!$canEdit && $forum_id) {
$AppUI->redirect('m=public&a=access_denied');
}
$forum_id = intval(w2PgetParam($_GET, 'forum_id', 0));
//Pull forum information
$q = new DBQuery();
$q->addTable('forums');
$q->addWhere('forums.forum_id = ' . (int) $forum_id);
$res = $q->exec(ADODB_FETCH_ASSOC);
echo db_error();
$forum_info = $q->fetchRow();
$status = isset($forum_info['forum_status']) ? $forum_info['forum_status'] : -1;
// get any project records denied from viewing
$projObj = new CProject();
//Pull project Information
$q = new DBQuery();
$q->addTable('projects', 'pr');
$q->addQuery('pr.project_id, project_name');
$q->addWhere('project_active = 1');
$q->addOrder('project_name');
$projObj->setAllowedSQL($AppUI->user_id, $q, null, 'pr');
if (isset($company_id)) {
$q->addWhere('project_company = ' . (int) $company_id);
}
$projects = array('0' => '') + $q->loadHashList();
echo db_error();
示例12: getEventsInWindow
public function getEventsInWindow($start_date, $end_date, $start_time, $end_time, $users = null)
{
global $AppUI;
if (!isset($users)) {
return false;
}
if (!count($users)) {
return false;
}
// Now build a query to find matching events.
$q = new DBQuery();
$q->addTable('events', 'e');
$q->addQuery('e.event_owner, ue.user_id, e.event_cwd, e.event_id, e.event_start_date, e.event_end_date');
$q->addJoin('user_events', 'ue', 'ue.event_id = e.event_id');
$q->addWhere('event_start_date >= \'' . $start_date . '\'
AND event_end_date <= \'' . $end_date . '\'
AND EXTRACT(HOUR_MINUTE FROM e.event_end_date) >= \'' . $start_time . '\'
AND EXTRACT(HOUR_MINUTE FROM e.event_start_date) <= \'' . $end_time . '\'
AND ( e.event_owner in (' . implode(',', $users) . ')
OR ue.user_id in (' . implode(',', $users) . ') )');
$result = $q->exec();
if (!$result) {
return false;
}
$eventlist = array();
while ($row = $q->fetchRow()) {
$eventlist[] = $row;
}
$q->clear();
return $eventlist;
}
示例13: parseFormatSysval
function parseFormatSysval($text, $syskey)
{
$q = new DBQuery();
$q->addTable('syskeys');
$q->addQuery('syskey_type, syskey_sep1, syskey_sep2');
$q->addWhere('syskey_id = ' . (int) $syskey);
$q->exec();
$row = $q->fetchRow();
$q->clear();
// type 0 = list
$sep1 = $row['syskey_sep1'];
// item separator
$sep2 = $row['syskey_sep2'];
// alias separator
// A bit of magic to handle newlines and returns as separators
// Missing sep1 is treated as a newline.
if (!isset($sep1) || empty($sep1)) {
$sep1 = "\n";
}
if ($sep1 == "\\n") {
$sep1 = "\n";
}
if ($sep1 == "\\r") {
$sep1 = "\r";
}
$temp = explode($sep1, $text);
$arr = array();
// We use trim() to make sure a numeric that has spaces
// is properly treated as a numeric
foreach ($temp as $item) {
if ($item) {
$sep2 = empty($sep2) ? "\n" : $sep2;
$temp2 = explode($sep2, $item);
if (isset($temp2[1])) {
$arr[mb_trim($temp2[0])] = mb_trim($temp2[1]);
} else {
$arr[mb_trim($temp2[0])] = mb_trim($temp2[0]);
}
}
}
return $arr;
}
示例14: getTaskName
function getTaskName()
{
if (!$this->file_task) {
return '';
}
$q = new DBQuery();
$q->addTable('tasks');
$q->addQuery('task_name');
$q->addWhere('task_id = ' . $this->file_task);
if (!$q->exec()) {
$q->clear();
return db_error();
}
$row = $q->fetchRow();
$q->clear();
return $row['task_name'];
}
示例15: load
function load()
{
global $db;
$q = new DBQuery();
$q->addTable('custom_fields_lists');
$q->addWhere("field_id = {$this->field_id}");
if (!($rs = $q->exec())) {
$q->clear();
return $db->ErrorMsg();
}
$this->options = array();
while ($opt_row = $q->fetchRow()) {
$this->options[] = $opt_row["list_value"];
}
$q->clear();
}