本文整理汇总了PHP中QueryGenerator::getWhereClause方法的典型用法代码示例。如果您正苦于以下问题:PHP QueryGenerator::getWhereClause方法的具体用法?PHP QueryGenerator::getWhereClause怎么用?PHP QueryGenerator::getWhereClause使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QueryGenerator
的用法示例。
在下文中一共展示了QueryGenerator::getWhereClause方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: QueryGenerator
echo "{$query}<br>";
testquery($query);
$current_user = $hold_user;
echo "<h2>Query as individual parts</h2>";
echo "<b>We can get the different parts of the query individually so we can construct specific queries easily</b><br>";
$queryGenerator = new QueryGenerator($moduleName, $current_user);
$queryGenerator->setFields(array('id', 'cf_681', 'accountname'));
echo "<b>Full query:</b><br>";
$query = $queryGenerator->getQuery();
echo "{$query}<br>";
echo "<b>SELECT:</b><br>";
echo $queryGenerator->getSelectClauseColumnSQL();
echo "<br><b>FROM:</b><br>";
echo $queryGenerator->getFromClause();
echo "<br><b>WHERE:</b><br>";
echo $queryGenerator->getWhereClause();
echo "<br>";
testquery($query);
echo "<h2>Query with conditions</h2>";
echo "<b>Supported operators:</b><br>";
echo " 'e' = = value (equals)<br>";
echo " 'n' = <> value (not equal)<br>";
echo " 's' = LIKE {$value}% (starts with)<br>";
echo " 'ew' = LIKE %{$value} (ends with)<br>";
echo " 'c' = LIKE %{$value}% (contains)<br>";
echo " 'k' = NOT LIKE %{$value}% (does not contain)<br>";
echo " 'l' = < value (less than)<br>";
echo " 'b' = < value (before, only for dates)<br>";
echo " 'g' = > value (greater than)<br>";
echo " 'a' = > value (after, only for dates)<br>";
echo " 'm' = <= value (less or equal)<br>";
示例2: foreach
$queryGenerator->startGroup('OR');
}
foreach ($Module_Status_Fields[$evstat] as $condition) {
$queryGenerator->addCondition($condition['field'], $condition['value'], $condition['operator'], $condition['glue']);
}
$queryGenerator->endGroup();
}
}
if ($encompas_group) {
$queryGenerator->endGroup();
}
}
}
$list_query = $queryGenerator->getQuery();
$userNameSql = getSqlForNameInDisplayFormat(array('first_name' => 'vtiger_users.first_name', 'last_name' => 'vtiger_users.last_name'), 'Users');
$list_query = "SELECT distinct vtiger_crmentity.crmid, vtiger_groups.groupname, {$userNameSql} as user_name, " . $queryGenerator->getSelectClauseColumnSQL() . $queryGenerator->getFromClause() . $queryGenerator->getWhereClause();
$list_array = array();
} else {
$list_query = getCalendar4YouListQuery($userid, $invites);
if ($record != "") {
$list_query .= " AND vtiger_crmentity.crmid = '" . $record . "'";
} else {
$list_query .= " AND vtiger_activity.date_start <= '" . $end_date . "'";
$list_query .= " AND vtiger_activity.due_date >= '" . $start_date . "'";
}
if (!$invites) {
$list_query .= " AND vtiger_crmentity.smownerid = ?";
$list_query .= " AND vtiger_activity.activitytype = ?";
$list_array = array($userid, $activitytype);
}
if (count($Event_Status) > 0) {
示例3: execute
function execute($fieldnames, $pagingModel = false)
{
if ($this->moduleName == 'Project') {
// Custom View
include_once 'modules/CustomView/CustomView.php';
include_once 'include/QueryGenerator/QueryGenerator.php';
include_once 'modules/Mobile/api/ws/Controller.php';
include_once 'include/DatabaseUtil.php';
$customView = new CustomView($this->moduleName);
$viewid = $customView->getViewId($this->moduleName);
$customview_html = $customView->getCustomViewCombo($viewid);
$viewinfo = $customView->getCustomViewByCvid($viewid);
global $current_user;
// Required for vtws_update API
$userid = $_SESSION['_authenticated_user_id'];
$current_user = CRMEntity::getInstance('Users');
$current_user = $current_user->retrieveCurrentUserInfoFromFile($userid);
$queryGenerator = new QueryGenerator($this->moduleName, $current_user);
if ($viewid != "0") {
$queryGenerator->initForCustomViewById($viewid);
} else {
$queryGenerator->initForDefaultCustomView();
}
$selectClause = sprintf("SELECT %s", implode(',', $fieldnames) . ",vtiger_project.projectid");
$fromClause = $queryGenerator->getFromClause();
$whereClause = $queryGenerator->getWhereClause();
$orderClause = "";
$groupClause = "";
$limitClause = $pagingModel ? " LIMIT {$pagingModel->currentCount()},{$pagingModel->limit()}" : "";
if (!empty($this->criterias)) {
$_sortCriteria = $this->criterias['_sort'];
if (!empty($_sortCriteria)) {
$orderClause = $_sortCriteria;
}
}
$query = sprintf("%s %s %s %s %s %s;", $selectClause, $fromClause, $whereClause, $orderClause, $groupClause, $limitClause);
global $adb;
$result = $adb->pquery($query, array());
$noofrows = $adb->num_rows($result);
$lstresult = array();
for ($i = 0; $i < $noofrows; $i++) {
$lstresult[$i]['firstname'] = $adb->query_result($result, $i, 'projectname');
$lstresult[$i]['id'] = "31x" . $adb->query_result($result, $i, 'projectid');
}
return $lstresult;
} else {
$selectClause = sprintf("SELECT %s", implode(',', $fieldnames));
$fromClause = sprintf("FROM %s", $this->moduleName);
$whereClause = "";
$orderClause = "";
$groupClause = "";
$limitClause = $pagingModel ? " LIMIT {$pagingModel->currentCount()},{$pagingModel->limit()}" : "";
if (!empty($this->criterias)) {
$_sortCriteria = $this->criterias['_sort'];
if (!empty($_sortCriteria)) {
$orderClause = $_sortCriteria;
}
}
$query = sprintf("%s %s %s %s %s %s;", $selectClause, $fromClause, $whereClause, $orderClause, $groupClause, $limitClause);
return vtws_query($query, $this->getUser());
}
}
示例4: addSearchConditions
public function addSearchConditions($query, $searchParams, $related_module)
{
if (!empty($searchParams)) {
$currentUserModel = Users_Record_Model::getCurrentUserModel();
$queryGenerator = new QueryGenerator($related_module, $currentUserModel);
$queryGenerator->parseAdvFilterList($searchParams);
$where = $queryGenerator->getWhereClause(true);
$query .= $where;
}
return $query;
}
示例5: getConditionValue
/**
*
* @param mixed $value
* @param String $operator
* @param WebserviceField $field
*/
private function getConditionValue($value, $operator, $field)
{
$operator = strtolower($operator);
$db = PearDatabase::getInstance();
$noncommaSeparatedFieldTypes = array('currency', 'percentage', 'double', 'integer', 'number');
if (in_array($field->getFieldDataType(), $noncommaSeparatedFieldTypes)) {
if (is_array($value)) {
$valueArray = $value;
} else {
$valueArray = array($value);
}
// if ($field->getFieldDataType() == 'multipicklist' && in_array($operator, array('e', 'n'))) {
// $valueArray = getCombinations($valueArray);
// foreach ($valueArray as $key => $value) {
// $valueArray[$key] = ltrim($value, ' |##| ');
// }
// }
} elseif (is_string($value)) {
$valueArray = explode(',', $value);
} elseif (is_array($value)) {
$valueArray = $value;
} else {
$valueArray = array($value);
}
$sql = array();
if ($operator == 'exists') {
global $current_user, $adb;
$mid = getTabModuleName($field->getTabId());
$qg = new QueryGenerator($mid, $current_user);
$qg->addCondition($field->getFieldName(), $value, 'e');
$sql[] = 'SELECT EXISTS(SELECT 1 ' . $qg->getFromClause() . $qg->getWhereClause() . ')';
return $sql;
}
if ($operator == 'i' or $operator == 'in' or $operator == 'ni' or $operator == 'nin') {
$vals = array_map(array($db, 'quote'), $valueArray);
$sql[] = (($operator == 'ni' or $operator == 'nin') ? ' NOT ' : '') . 'IN (' . implode(',', $vals) . ')';
return $sql;
}
if ($operator == 'between' || $operator == 'bw' || $operator == 'notequal') {
if ($field->getFieldName() == 'birthday') {
$valueArray[0] = getValidDBInsertDateTimeValue($valueArray[0]);
$valueArray[1] = getValidDBInsertDateTimeValue($valueArray[1]);
$sql[] = "BETWEEN DATE_FORMAT(" . $db->quote($valueArray[0]) . ", '%m%d') AND " . "DATE_FORMAT(" . $db->quote($valueArray[1]) . ", '%m%d')";
} else {
if ($this->isDateType($field->getFieldDataType())) {
$valueArray[0] = getValidDBInsertDateTimeValue($valueArray[0]);
$valueArray[1] = getValidDBInsertDateTimeValue($valueArray[1]);
}
$sql[] = "BETWEEN " . $db->quote($valueArray[0]) . " AND " . $db->quote($valueArray[1]);
}
return $sql;
}
$yes = strtolower(getTranslatedString('yes'));
$no = strtolower(getTranslatedString('no'));
foreach ($valueArray as $value) {
if (!$this->isStringType($field->getFieldDataType())) {
$value = trim($value);
}
if ($operator == 'empty' || $operator == 'y') {
$sql[] = sprintf("IS NULL OR %s = ''", $this->getSQLColumn($field->getFieldName()));
continue;
}
if ($operator == 'ny') {
$sql[] = sprintf("IS NOT NULL AND %s != ''", $this->getSQLColumn($field->getFieldName()));
continue;
}
if (strtolower(trim($value)) == 'null' || trim($value) == '' && !$this->isStringType($field->getFieldDataType()) && ($operator == 'e' || $operator == 'n')) {
if ($operator == 'e') {
$sql[] = "IS NULL";
continue;
}
$sql[] = "IS NOT NULL";
continue;
} elseif ($field->getFieldDataType() == 'boolean') {
$value = strtolower($value);
if ($value == 'yes' or $value == $yes) {
$value = 1;
} elseif ($value == 'no' or $value == $no) {
$value = 0;
}
} elseif ($this->isDateType($field->getFieldDataType())) {
$value = getValidDBInsertDateTimeValue($value);
if (empty($value)) {
$sql[] = 'IS NULL or ' . $field->getTableName() . '.' . $field->getFieldName() . " = ''";
return $sql;
}
} elseif ($field->getFieldDataType() == 'picklist' || $field->getFieldDataType() == 'multipicklist') {
if (!isValueInPicklist($value, $field->getFieldName())) {
$value = getTranslationKeyFromTranslatedValue($this->module, $value);
}
} else {
if ($field->getFieldDataType() === 'currency') {
$uiType = $field->getUIType();
if ($uiType == 72) {
//.........这里部分代码省略.........