本文整理汇总了PHP中DBQuery::addJoin方法的典型用法代码示例。如果您正苦于以下问题:PHP DBQuery::addJoin方法的具体用法?PHP DBQuery::addJoin怎么用?PHP DBQuery::addJoin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DBQuery
的用法示例。
在下文中一共展示了DBQuery::addJoin方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getCompanyInfo
function getCompanyInfo($company_id)
{
global $AppUI;
$q = new DBQuery();
$q->addTable('companies', 'c');
$q->addJoin('users', 'u', 'u.user_id = c.company_owner');
$q->addJoin('contacts', 'co', 'u.user_contact = co.contact_id');
$q->addQuery('c.*, CONCAT(contact_first_name, " ", contact_last_name) AS contact_name');
$q->addWhere('c.company_id = ' . $company_id);
$company = $q->loadHash();
if (!$company) {
$AppUI->setMsg('Missing company ID', UI_MSG_ERROR);
echo $AppUI->getMsg();
return;
}
include 'modules/public/resources.info.php';
}
示例2: load
function load($oid = null, $strip = true)
{
$result = parent::load($oid, $strip);
if ($result && $oid) {
$working_hours = dPgetConfig('daily_working_hours') ? dPgetConfig('daily_working_hours') : 8;
$q = new DBQuery();
$q->addTable('projects');
$q->addQuery(" SUM(t1.task_duration * t1.task_percent_complete" . " * IF(t1.task_duration_type = 24, {$working_hours}, t1.task_duration_type))" . " / SUM(t1.task_duration * IF(t1.task_duration_type = 24, {$working_hours}" . ", t1.task_duration_type)) AS project_percent_complete");
$q->addJoin('tasks', 't1', 'projects.project_id = t1.task_project');
$q->addWhere(" project_id = {$oid} AND t1.task_id = t1.task_parent");
$this->project_percent_complete = $q->loadResult();
}
return $result;
}
示例3: load
function load($oid = null, $strip = true)
{
$result = parent::load($oid, $strip);
if ($result && $oid) {
$working_hours = $dPconfig['daily_working_hours'] ? $dPconfig['daily_working_hours'] : 8;
$q = new DBQuery();
$q->addTable('projects');
$q->addQuery(' SUM(t1.task_duration * t1.task_percent_complete' . ' * IF(t1.task_duration_type = 24, ' . $working_hours . ', t1.task_duration_type))' . ' / SUM(t1.task_duration * IF(t1.task_duration_type = 24, ' . $working_hours . ', t1.task_duration_type)) AS project_percent_complete');
$q->addJoin('tasks', 't1', 'projects.project_id = t1.task_project');
$q->addWhere(' project_id = ' . $oid . ' AND t1.task_id = t1.task_parent');
$this->project_percent_complete = $q->loadResult();
}
return $result;
}
示例4: load
function load($oid = null, $strip = true)
{
$result = parent::load($oid, $strip);
if ($result && $oid) {
$q = new DBQuery();
$q->addTable('projects');
$q->addQuery('SUM(t1.task_duration*t1.task_duration_type*t1.task_percent_complete) /
SUM(t1.task_duration*t1.task_duration_type)
AS project_percent_complete');
$q->addJoin('tasks', 't1', 'projects.project_id = t1.task_project');
$q->addWhere(" project_id = {$oid}");
$this->project_percent_complete = $q->loadResult();
}
return $result;
}
示例5: sendNewPass
function sendNewPass()
{
global $AppUI;
$_live_site = w2PgetConfig('base_url');
$_sitename = w2PgetConfig('company_name');
// ensure no malicous sql gets past
$checkusername = trim(w2PgetParam($_POST, 'checkusername', ''));
$checkusername = db_escape($checkusername);
$confirmEmail = trim(w2PgetParam($_POST, 'checkemail', ''));
$confirmEmail = strtolower(db_escape($confirmEmail));
$q = new DBQuery();
$q->addTable('users');
$q->addJoin('contacts', '', 'user_contact = contact_id', 'inner');
$q->addQuery('user_id');
$q->addWhere('user_username = \'' . $checkusername . '\'');
$q->addWhere('LOWER(contact_email) = \'' . $confirmEmail . '\'');
if (!($user_id = $q->loadResult()) || !$checkusername || !$confirmEmail) {
$AppUI->setMsg('Invalid username or email.', UI_MSG_ERROR);
$AppUI->redirect();
}
$newpass = makePass();
$message = $AppUI->_('sendpass0', UI_OUTPUT_RAW) . ' ' . $checkusername . ' ' . $AppUI->_('sendpass1', UI_OUTPUT_RAW) . ' ' . $_live_site . ' ' . $AppUI->_('sendpass2', UI_OUTPUT_RAW) . ' ' . $newpass . ' ' . $AppUI->_('sendpass3', UI_OUTPUT_RAW);
$subject = $_sitename . ' :: ' . $AppUI->_('sendpass4', UI_OUTPUT_RAW) . ' - ' . $checkusername;
$m = new Mail();
// create the mail
$m->To($confirmEmail);
$m->Subject($subject);
$m->Body($message, isset($GLOBALS['locale_char_set']) ? $GLOBALS['locale_char_set'] : '');
// set the body
$m->Send();
// send the mail
$newpass = md5($newpass);
$q->addTable('users');
$q->addUpdate('user_password', $newpass);
$q->addWhere('user_id=' . $user_id);
$cur = $q->exec();
if (!$cur) {
die('SQL error' . $database->stderr(true));
} else {
$AppUI->setMsg('New User Password created and emailed to you');
$AppUI->redirect();
}
}
示例6: 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;
}
示例7: dPgetParam
$a_orig = dPgetParam($_REQUEST, 'a_orig', $a);
$projectStatus = dPgetSysVal('ProjectStatus');
$projectStatus = arrayMerge(array('-2' => $AppUI->_('All w/o in progress'), '-3' => $AppUI->_($AppUI->user_id == $user_id ? 'My projects' : "User's projects")), $projectStatus);
$pjobj =& new CProject();
$working_hours = $dPconfig['daily_working_hours'];
$q = new DBQuery();
/*
* Load department info for the case where one
* wants to see the ProjectsWithOwnerInDeparment (PwOiD)
* instead of the projects related to the given department.
*/
$owner_ids = array();
if ($addPwOiD && $department > 0) {
$q->addTable('users');
$q->addQuery('user_id');
$q->addJoin('contacts', 'c', 'c.contact_id = user_contact');
$q->addWhere('c.contact_department = ' . $department);
$owner_ids = $q->loadColumn();
$q->clear();
}
// pull valid projects and their percent complete information
// GJB: Note that we have to special case duration type 24 and this refers to the hours in a day, NOT 24 hours
$q->addTable('projects', 'p');
$q->addQuery('DISTINCT p.project_id, project_color_identifier, project_name, project_start_date' . ', project_end_date, max(t1.task_end_date) AS project_actual_end_date' . ', SUM(task_duration * task_percent_complete * IF(task_duration_type = 24, ' . $working_hours . ', task_duration_type))' . ' / SUM(task_duration * IF(task_duration_type = 24, ' . $working_hours . ', task_duration_type)) AS project_percent_complete' . ', project_status');
$q->addJoin('tasks', 't1', 'p.project_id = t1.task_project');
$q->addJoin('companies', 'c1', 'p.project_company = c1.company_id');
if ($department > 0) {
$q->addJoin('project_departments', 'pd', 'pd.project_id = p.project_id');
if (!$addPwOiD) {
$q->addWhere('pd.department_id = ' . $department);
} else {
示例8: CProject
$filter1[] = ' project_status = ' . $proFilter;
}
}
if ($company_id != 0) {
$filter1[] = ' project_company = ' . $company_id;
}
if ($showInactive != '1') {
$filter1[] = ' project_status <> 7';
}
$pjobj =& new CProject();
$allowed_projects = $pjobj->getAllowedSQL($AppUI->user_id);
$where = array_merge($filter1, $allowed_projects);
// pull valid projects and their percent complete information
$q = new DBQuery();
$q->addTable('tasks', 't');
$q->addJoin('user_tasks', 'ut', 't.task_id = ut.task_id');
$q->addJoin('users', 'u', 'u.user_id = ut.user_id');
$q->addJoin('projects', 'p', 'p.project_id = t.task_project');
$q->addJoin('companies', 'c', 'p.project_company = c.company_id');
$q->addQuery('u.user_username, t.task_name, t.task_start_date, t.task_milestone' . ', ut.perc_assignment, t.task_end_date, t.task_dynamic' . ', p.project_color_identifier, p.project_name');
$q->addOrder('t.task_name, t.task_start_date, t.task_end_date, ut.perc_assignment');
$tasks = $q->loadList();
$q->clear();
$q->addTable('user_tasks', 'ut');
$q->innerJoin('users', 'u', 'u.user_id = ut.user_id');
$q->innerJoin('tasks', 't', 't.task_id = ut.task_id');
$q->addQuery('min(t.task_start_date) AS task_min_date, max(t.task_end_date) AS task_max_date');
$taskMinMax = $q->loadList();
$q->clear();
$width = dPgetParam($_GET, 'width', 600);
$start_date = dPgetParam($_GET, 'start_date', 0);
示例9: CDate
$messages = $q->loadList();
$x = false;
$date = new CDate();
$pdfdata = array();
$pdfhead = array('Date', 'User', 'Message');
$new_messages = array();
foreach ($messages as $row) {
// Find the parent message - the topic.
if ($row['message_id'] == $message_id) {
$topic = $row['message_title'];
}
$q = new DBQuery();
$q->addTable('forum_messages');
$q->addTable('users', 'u');
$q->addQuery('DISTINCT contact_email, contact_first_name, contact_last_name, user_username');
$q->addJoin('contacts', 'con', 'contact_id = user_contact');
$q->addWhere('u.user_id = ' . $row["message_editor"]);
$editor = $q->loadList();
$date = intval($row["message_date"]) ? new CDate($row["message_date"]) : null;
$pdfdata[] = array($row['message_date'], $row['contact_first_name'] . ' ' . $row['contact_last_name'], '<b>' . $row['message_title'] . '</b>
' . $row['message_body']);
}
$font_dir = DP_BASE_DIR . '/lib/ezpdf/fonts';
$temp_dir = DP_BASE_DIR . '/files/temp';
require $AppUI->getLibraryClass('ezpdf/class.ezpdf');
$pdf =& new Cezpdf($paper = 'A4', $orientation = 'portrait');
$pdf->ezSetCmMargins(1, 2, 1.5, 1.5);
$pdf->selectFont("{$font_dir}/Helvetica.afm");
$pdf->ezText('Project: ' . $forum['project_name'] . ' Forum: ' . $forum['forum_name']);
$pdf->ezText('Topic: ' . $topic);
$pdf->ezText('');
示例10: getEventsInWindow
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 = db_fetch_assoc($result)) {
$eventlist[] = $row;
}
$q->clear();
return $eventlist;
}
示例11: CCompany
$obj = new CCompany();
$allowedCompanies = $obj->getAllowedRecords($AppUI->user_id, 'company_id, company_name');
$company_type_filter = $currentTabId;
//Not Defined
$companiesType = true;
if ($currentTabName == "All Companies") {
$companiesType = false;
}
if ($currentTabName == "Not Applicable") {
$company_type_filter = 0;
}
// retrieve list of records
$q = new DBQuery();
$q->addTable('companies', 'c');
$q->addQuery('c.company_id, c.company_name, c.company_type, c.company_description, count(distinct p.project_id) as countp, count(distinct p2.project_id) as inactive, con.contact_first_name, con.contact_last_name');
$q->addJoin('projects', 'p', 'c.company_id = p.project_company AND p.project_status <> 7');
$q->addJoin('users', 'u', 'c.company_owner = u.user_id');
$q->addJoin('contacts', 'con', 'u.user_contact = con.contact_id');
$q->addJoin('projects', 'p2', 'c.company_id = p2.project_company AND p2.project_status = 7');
if (count($allowedCompanies) > 0) {
$q->addWhere('c.company_id IN (' . implode(',', array_keys($allowedCompanies)) . ')');
}
if ($companiesType) {
$q->addWhere('c.company_type = ' . $company_type_filter);
}
if ($search_string != "") {
$q->addWhere("c.company_name LIKE '%{$search_string}%'");
}
if ($owner_filter_id > 0) {
$q->addWhere("c.company_owner = {$owner_filter_id} ");
}
示例12: isset
<?php
/* DEPARTMENTS $Id: addedit.php,v 1.24 2005/04/08 13:41:51 gregorerhardt Exp $ */
// Add / Edit Company
$dept_id = isset($_GET['dept_id']) ? $_GET['dept_id'] : 0;
$company_id = isset($_GET['company_id']) ? $_GET['company_id'] : 0;
// check permissions for this department
$canEdit = !getDenyEdit($m, $dept_id);
if (!$canEdit) {
$AppUI->redirect("m=public&a=access_denied");
}
// pull data for this department
$q = new DBQuery();
$q->addTable('departments', 'dep');
$q->addQuery('dep.*, company_name');
$q->addJoin('companies', 'com', 'com.company_id = dep.dept_company');
$q->addWhere('dep.dept_id = ' . $dept_id);
$sql = $q->prepare();
$q->clear();
if (!db_loadHash($sql, $drow) && $dept_id > 0) {
$titleBlock = new CTitleBlock('Invalid Department ID', 'users.gif', $m, "{$m}.{$a}");
$titleBlock->addCrumb("?m=companies", "companies list");
if ($company_id) {
$titleBlock->addCrumb("?m=companies&a=view&company_id={$company_id}", "view this company");
}
$titleBlock->show();
} else {
##echo $sql.db_error();##
$company_id = $dept_id ? $drow['dept_company'] : $company_id;
// check if valid company
$q = new DBQuery();
示例13: getAssignedProjectsInRows
function getAssignedProjectsInRows($userId)
{
$q = new DBQuery();
$q->addQuery('project_id, project_status, project_name, project_description' . ', project_short_name');
$q->addTable('projects');
$q->addJoin('tasks', 't', 't.task_project = project_id');
$q->addJoin('user_tasks', 'ut', 'ut.task_id = t.task_id');
$q->addWhere('ut.user_id = ' . $userId);
$q->addGroup('project_id');
$q->addOrder('project_name');
$this->setAllowedSQL($userId, $q);
$allowedProjectRows = $q->exec();
return $allowedProjectRows;
}
示例14: while
if ($boot_query_row) {
$boot_user_session = $boot_query_row['session_id'];
$boot_user_log_id = $boot_query_row['user_access_log_id'];
} else {
$r->clear();
}
}
} while ($boot_query_row);
$msg = $boot_user_name . ' logged out by ' . $AppUI->user_first_name . ' ' . $AppUI->user_last_name;
$AppUI->setMsg($msg, UI_MSG_OK);
$AppUI->redirect('m=admin&tab=3');
}
$q = new DBQuery();
$q->addTable('sessions', 's');
$q->addQuery('DISTINCT(session_id), user_access_log_id, u.user_id as u_user_id, user_username,' . ' contact_last_name, contact_first_name, company_name, contact_company,' . ' date_time_in, user_ip');
$q->addJoin('user_access_log', 'ual', 'session_user = user_access_log_id');
$q->addJoin('users', 'u', 'ual.user_id = u.user_id');
$q->addJoin('contacts', 'con', 'u.user_contact = contact_id');
$q->addJoin('companies', 'com', 'contact_company = company_id');
$q->addOrder($orderby);
$rows = $q->loadList();
$q->clear();
$tab = (int) dPgetParam($_REQUEST, 'tab', 0);
?>
<script language="JavaScript" type="text/javascript">
//<![CDATA[
function logoutSession(sessionID, logID, userID, userName) {
var frm;
frm = document.getElementById("frmSessions");
frm.out_session.value = sessionID;
frm.out_user_log_id.value = logID;
示例15: CProject
<th width="100%"><?php
echo $AppUI->_('Comments');
?>
</th>
<th></th>
</tr>
<?php
// Winnow out the tasks we are not allowed to view.
$perms =& $AppUI->acl();
$project =& new CProject();
// Pull the task comments
$q = new DBQuery();
$q->addTable('task_log');
$q->addQuery('task_log.*, user_username, task_id');
$q->addQuery('billingcode_name as task_log_costcode');
$q->addJoin('users', 'u', 'user_id = task_log_creator');
$q->addJoin('tasks', 't', 'task_log_task = t.task_id');
$q->addJoin('billingcode', 'b', 'task_log.task_log_costcode = billingcode_id');
$q->addWhere('task_project = ' . $project_id);
if ($user_id > 0) {
$q->addWhere('task_log_creator = ' . $user_id);
}
if ($hide_inactive) {
$q->addWhere('task_status >= 0');
}
if ($hide_complete) {
$q->addWhere('task_percent_complete < 100');
}
if ($cost_code != '0') {
$q->addWhere('task_log_costcode = "' . $cost_code . '"');
}