本文整理汇总了PHP中w2p_Database_Query::fetchRow方法的典型用法代码示例。如果您正苦于以下问题:PHP w2p_Database_Query::fetchRow方法的具体用法?PHP w2p_Database_Query::fetchRow怎么用?PHP w2p_Database_Query::fetchRow使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类w2p_Database_Query
的用法示例。
在下文中一共展示了w2p_Database_Query::fetchRow方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: load
public function load()
{
global $db;
$q = new w2p_Database_Query();
$q->addTable('custom_fields_lists');
$q->addWhere('field_id = ' . $this->field_id);
$q->addOrder('list_value');
if (!$q->exec()) {
return $db->ErrorMsg();
}
while ($opt_row = $q->fetchRow()) {
$this->options[$opt_row['list_option_id']] = $opt_row['list_value'];
}
}
示例2: authenticate
public function authenticate($username, $password)
{
global $db, $AppUI;
$this->username = $username;
$q = new w2p_Database_Query();
$q->addTable('users');
$q->addQuery('user_id, user_password');
$q->addWhere("user_username = '{$username}'");
$q->addWhere("user_password = '" . MD5($password) . "'");
$q->exec();
if ($row = $q->fetchRow()) {
$this->user_id = $row['user_id'];
return true;
}
return false;
}
示例3: load
public function load($object_id)
{
// Override Load Method for List type Classes
$q = new w2p_Database_Query();
$q->addTable('custom_fields_values');
$q->addWhere('value_field_id = ' . $this->field_id);
$q->addWhere('value_object_id = ' . (int) $object_id);
$rs = $q->exec();
$row = $q->fetchRow();
$value_id = $row['value_id'];
$value_charvalue = $row['value_charvalue'];
$value_intvalue = $row['value_intvalue'];
if ($value_id != null) {
$this->value_id = $value_id;
$this->value_charvalue = $value_charvalue;
$this->value_intvalue = $value_intvalue;
}
}
示例4: store
public function store(CAppUI $AppUI = null)
{
global $AppUI;
$perms = $AppUI->acl();
$stored = false;
$this->_error = $this->check();
if (count($this->_error)) {
return $this->_error;
}
$q = new w2p_Database_Query();
if ($this->message_id && $perms->checkModuleItem('forums', 'edit', $this->forum_id)) {
$q->setDelete('forum_visits');
$q->addWhere('visit_message = ' . (int) $this->message_id);
$q->exec();
if ($msg = parent::store()) {
return $msg;
}
$stored = true;
}
if (0 == $this->message_id && $perms->checkModuleItem('forums', 'add')) {
$this->message_date = $q->dbfnNowWithTZ();
if ($msg = parent::store()) {
return $msg;
}
$q->addTable('forum_messages');
$q->addQuery('count(message_id), MAX(message_date)');
$q->addWhere('message_forum = ' . (int) $this->message_forum);
$reply = $q->fetchRow();
//update forum descriptor
$forum = new CForum();
$forum->load($AppUI, $this->message_forum);
$forum->forum_message_count = $reply[0];
/*
* Note: the message_date here has already been adjusted for the
* timezone above, so don't do it again!
*/
$forum->forum_last_date = $this->message_date;
$forum->forum_last_id = $this->message_id;
$forum->store($AppUI);
$this->sendWatchMail(false);
$stored = true;
}
return $stored;
}
示例5: authenticate
public function authenticate($username, $password)
{
global $db, $AppUI;
$this->username = $username;
$q = new w2p_Database_Query();
$q->addTable('users');
$q->addQuery('user_id, user_password');
$q->addWhere('user_username = \'' . $username . '\'');
if (!($rs = $q->exec())) {
$q->clear();
return false;
}
if (!($row = $q->fetchRow())) {
$q->clear();
return false;
}
$this->user_id = $row['user_id'];
$q->clear();
if (MD5($password) == $row['user_password']) {
return true;
}
return false;
}
示例6: 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 = canView('tasks');
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('ut.user_task_priority');
$q->addQuery('task_priority, task_percent_complete');
$q->addQuery('task_duration, task_duration_type');
示例7: COUNT
$q->leftJoin('departments', 'departments', 'departments.dept_id = project_departments.department_id OR dept_id IS NULL');
$q->addWhere('t1.task_id = t1.task_parent');
$q->addWhere('projects.project_id=' . $project_id);
if (count($allowedProjects)) {
$q->addWhere($allowedProjects);
}
$q->addGroup('projects.project_id');
$q2 = new w2p_Database_Query();
$q2 = $q;
$q2->addQuery('projects.project_id, COUNT(t1.task_id) as total_tasks');
$perms =& $AppUI->acl();
$projects = array();
if ($canViewTasks) {
$prc = $q->exec();
echo db_error();
while ($row = $q->fetchRow()) {
$projects[$row['project_id']] = $row;
}
$prc2 = $q2->exec();
echo db_error();
while ($row2 = $q2->fetchRow()) {
$projects[$row2['project_id']] = !$projects[$row2['project_id']] ? array() : $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('count(tasks.task_parent) as children');
$q->addQuery('task_pinned, pin.user_id as pin_user');
示例8: 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.
*/
public function remind($module, $type, $id, $owner, &$args)
{
global $locale_char_set, $AppUI;
$q = new w2p_Database_Query();
// 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 w2p_Utilities_Date();
if (!$today->isWorkingDay()) {
return true;
}
// Check if the task is completed
if ($this->task_percent_complete == 100) {
return -1;
}
$contacts = $this->getAssigned();
// 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->addJoin('contacts', 'c', 'c.contact_id = u.user_contact', 'inner');
$q->addQuery('c.contact_id, contact_first_name, contact_last_name, contact_email');
$q->addWhere('u.user_id = ' . (int) $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 w2p_Utilities_Date($this->task_start_date);
$expires = new w2p_Utilities_Date($this->task_end_date);
$now = new w2p_Utilities_Date();
$diff = $expires->dateDiff($now);
$diff *= w2p_Utilities_Date::compare($expires, $now);
$prefix = $AppUI->_('Task Due', UI_OUTPUT_RAW);
if ($diff == 0) {
$msg = $AppUI->_('TODAY', UI_OUTPUT_RAW);
} elseif ($diff == 1) {
$msg = $AppUI->_('TOMORROW', UI_OUTPUT_RAW);
} elseif ($diff < 0) {
$msg = $AppUI->_(array('OVERDUE', abs($diff), 'DAYS'));
$prefix = $AppUI->_('Task', UI_OUTPUT_RAW);
} else {
$msg = $AppUI->_(array($diff, 'DAYS'));
}
$project = new CProject();
$project_name = $project->load($this->task_project)->project_name;
// Check to see that the project is both active and not a template
if (!$project->project_active || $project->project_status == w2PgetConfig('template_projects_status_id', 0)) {
return -1;
}
$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) . ': START-TIME' . "\n" . $AppUI->_('Finish Date', UI_OUTPUT_RAW) . ': END-TIME' . "\n" . $AppUI->_('URL', UI_OUTPUT_RAW) . ': ' . W2P_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 || $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 w2p_Utilities_Mail();
$mail->Subject($subject, $locale_char_set);
foreach ($contacts as $contact) {
$user_id = CUser::getUserIdByContactID($contact['contact_id']);
$AppUI->loadPrefs($user_id);
$df = $AppUI->getPref('DISPLAYFORMAT');
$tz = $AppUI->getPref('TIMEZONE');
$body = str_replace('START-TIME', $starts->convertTZ($tz)->format($df), $body);
$body = str_replace('END-TIME', $expires->convertTZ($tz)->format($df), $body);
$mail->Body($body, $locale_char_set);
if ($mail->ValidEmail($contact['contact_email'])) {
$mail->To($contact['contact_email'], true);
$mail->Send();
}
}
return true;
}
示例9: addHistory
if ($_GET['out_session'] && $_GET['out_user_log_id']) {
$boot_user_session = $_GET['out_session'];
$boot_user_log_id = w2PgetParam($_GET, 'out_user_log_id', null);
$boot_query_row = false;
} else {
if ($canEdit && $canDelete && $logoutUserFlag) {
// query for all sessions open for a given user
$r = new w2p_Database_Query();
$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 = ' . (int) $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);
w2PsessionDestroy($boot_user_session, $boot_user_log_id);
}
if ($boot_query_row) {
示例10: get_object_sections
public function get_object_sections($section_value = null, $return_hidden = 1, $object_type = null, $limit_clause = null)
{
switch (strtolower(trim($object_type))) {
case 'aco':
$object_type = 'aco';
$table = $this->_db_acl_prefix . 'aco_sections';
break;
case 'aro':
$object_type = 'aro';
$table = $this->_db_acl_prefix . 'aro_sections';
break;
case 'axo':
$object_type = 'axo';
$table = $this->_db_acl_prefix . 'axo_sections';
break;
default:
$this->debug_text('get_object_sections(): Invalid Object Type: ' . $object_type);
return false;
}
$this->debug_text("get_objects(): Section Value: {$section_value} Object Type: {$object_type}");
// $query = 'SELECT id, value, name, order_value, hidden FROM '. $table;
$q = new w2p_Database_Query();
$q->addTable($table);
$q->addQuery('id, value, name, order_value, hidden');
if (!empty($section_value)) {
$q->addWhere('value=' . $this->db->quote($section_value));
}
if ($return_hidden == 0) {
$q->addWhere('hidden=0');
}
if (!empty($limit_clause)) {
$q->addWhere($limit_clause);
}
$q->addOrder('order_value');
$rs = $q->exec();
$retarr = array();
while ($row = $q->fetchRow()) {
$retarr[] = array('id' => $row[0], 'value' => $row[1], 'name' => $row[2], 'order_value' => $row[3], 'hidden' => $row[4]);
}
$q->clear();
// Return objects
return $retarr;
}
示例11: parseFormatSysval
function parseFormatSysval($text, $syskey)
{
$q = new w2p_Database_Query();
$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;
}
示例12: array
$task_parent_options = '';
// Now lets get non-root tasks, grouped by the task parent
$q = new w2p_Database_Query();
$q->addQuery('task_id, task_name, task_end_date, task_start_date, task_milestone, task_parent, task_dynamic');
$q->addTable('tasks');
$q->addWhere('task_project = ' . (int) $task_project);
$q->addWhere('task_id <> task_parent');
$q->addOrder('task_start_date');
$parents = array();
$projTasksWithEndDates = array(0 => $AppUI->_('None'));
//arrays contains task end date info for setting new task start date as maximum end date of dependenced tasks
global $all_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_pd($root_task, $parents, $all_tasks);
}
}
$project = new CProject();
示例13: 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 w2p_Database_Query();
$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;
}
示例14: 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 w2p_Database_Query();
$q->addTable('users', 'u');
$q->addQuery('contact_first_name, contact_last_name, contact_email');
$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 user_id, contact_first_name, contact_last_name, contact_email');
$q->leftJoin('contacts', 'con', '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 w2p_Utilities_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;
}