本文整理匯總了PHP中DbCommand::where方法的典型用法代碼示例。如果您正苦於以下問題:PHP DbCommand::where方法的具體用法?PHP DbCommand::where怎麽用?PHP DbCommand::where使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類DbCommand
的用法示例。
在下文中一共展示了DbCommand::where方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: _applyFolderConditions
/**
* Applies WHERE conditions to a DbCommand query for folders.
*
* @access private
* @param DbCommand $query
* @param FolderCriteriaModel $criteria
*/
private function _applyFolderConditions($query, FolderCriteriaModel $criteria)
{
$whereConditions = array();
$whereParams = array();
if ($criteria->id) {
$whereConditions[] = DbHelper::parseParam('f.id', $criteria->id, $whereParams);
}
if ($criteria->sourceId) {
$whereConditions[] = DbHelper::parseParam('f.sourceId', $criteria->sourceId, $whereParams);
}
if ($criteria->parentId) {
// Set parentId to null if we're looking for folders with no parents.
if ($criteria->parentId == FolderCriteriaModel::AssetsNoParent) {
$criteria->parentId = null;
}
$whereConditions[] = DbHelper::parseParam('f.parentId', array($criteria->parentId), $whereParams);
}
if ($criteria->name) {
$whereConditions[] = DbHelper::parseParam('f.name', $criteria->name, $whereParams);
}
if (!is_null($criteria->fullPath)) {
$whereConditions[] = DbHelper::parseParam('f.fullPath', $criteria->fullPath, $whereParams);
}
if (count($whereConditions) == 1) {
$query->where($whereConditions[0], $whereParams);
} else {
array_unshift($whereConditions, 'and');
$query->where($whereConditions, $whereParams);
}
}
示例2: _applyFolderConditions
/**
* Applies WHERE conditions to a DbCommand query for folders.
*
* @param DbCommand $query
* @param FolderCriteriaModel $criteria
*
* @return null
*/
private function _applyFolderConditions($query, FolderCriteriaModel $criteria)
{
$whereConditions = array();
$whereParams = array();
if ($criteria->id) {
$whereConditions[] = DbHelper::parseParam('f.id', $criteria->id, $whereParams);
}
if ($criteria->sourceId) {
$whereConditions[] = DbHelper::parseParam('f.sourceId', $criteria->sourceId, $whereParams);
}
if ($criteria->parentId) {
$whereConditions[] = DbHelper::parseParam('f.parentId', $criteria->parentId, $whereParams);
}
if ($criteria->name) {
$whereConditions[] = DbHelper::parseParam('f.name', $criteria->name, $whereParams);
}
if (!is_null($criteria->path)) {
// This folder has a comma in it.
if (strpos($criteria->path, ',') !== false) {
// Escape the comma.
$condition = DbHelper::parseParam('f.path', str_replace(',', '\\,', $criteria->path), $whereParams);
$lastKey = key(array_slice($whereParams, -1, 1, true));
// Now un-escape it.
$whereParams[$lastKey] = str_replace('\\,', ',', $whereParams[$lastKey]);
} else {
$condition = DbHelper::parseParam('f.path', $criteria->path, $whereParams);
}
$whereConditions[] = $condition;
}
if (count($whereConditions) == 1) {
$query->where($whereConditions[0], $whereParams);
} else {
array_unshift($whereConditions, 'and');
$query->where($whereConditions, $whereParams);
}
}
示例3: _applyUserConditions
/**
* Applies WHERE conditions to a DbCommand query for users.
*
* @access private
* @param DbCommand $query
* @param $criteria
* @return void
*/
private function _applyUserConditions($query, $criteria)
{
$whereConditions = array();
$whereParams = array();
if ($criteria->id) {
$whereConditions[] = DbHelper::parseParam('u.id', $criteria->id, $whereParams);
}
if ($criteria->groupId || $criteria->group) {
$query->join('usergroups_users gu', 'gu.userId = u.id');
if ($criteria->groupId) {
$whereConditions[] = DbHelper::parseParam('gu.groupId', $criteria->groupId, $whereParams);
}
if ($criteria->group) {
$query->join('usergroups g', 'g.id = gu.groupId');
$whereConditions[] = DbHelper::parseParam('g.handle', $criteria->group, $whereParams);
}
}
if ($criteria->username) {
$whereConditions[] = DbHelper::parseParam('u.username', $criteria->username, $whereParams);
}
if ($criteria->firstName) {
$whereConditions[] = DbHelper::parseParam('u.firstName', $criteria->firstName, $whereParams);
}
if ($criteria->lastName) {
$whereConditions[] = DbHelper::parseParam('u.lastName', $criteria->lastName, $whereParams);
}
if ($criteria->email) {
$whereConditions[] = DbHelper::parseParam('u.email', $criteria->email, $whereParams);
}
if ($criteria->admin) {
$whereConditions[] = DbHelper::parseParam('u.admin', 1, $whereParams);
}
if ($criteria->status) {
$whereConditions[] = DbHelper::parseParam('u.status', $criteria->status, $whereParams);
}
if ($criteria->lastLoginDate) {
$whereConditions[] = DbHelper::parseParam('u.lastLoginDate', $criteria->lastLoginDate, $whereParams);
}
if ($whereConditions) {
array_unshift($whereConditions, 'and');
$query->where($whereConditions, $whereParams);
}
}