本文整理汇总了PHP中Doctrine_Query::addWhere方法的典型用法代码示例。如果您正苦于以下问题:PHP Doctrine_Query::addWhere方法的具体用法?PHP Doctrine_Query::addWhere怎么用?PHP Doctrine_Query::addWhere使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine_Query
的用法示例。
在下文中一共展示了Doctrine_Query::addWhere方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addIsPublishedColumnQuery
protected function addIsPublishedColumnQuery(Doctrine_Query $query, $field, $values)
{
if ($values) {
$query->addWhere('r.date_published < NOW()');
} else {
$query->addWhere('r.date_published >= NOW() OR r.date_published IS NULL');
}
}
示例2: buildQuery
function buildQuery(Doctrine_Query $query)
{
$query->leftJoin('swBlogPost.Translation');
$query->leftJoin('swBlogPost.swBlogPostTags t');
$query->leftJoin('t.Translation tt');
if (strlen($this->getValue('tag')) > 0) {
$query->addWhere('tt.name = ? and tt.lang = ?', array($this->getValue('tag'), sfContext::getInstance()->getUser()->getCulture()));
}
if (!is_null($this->getValue('published'))) {
$query->addWhere('swBlogPost.published = ?', $this->getValue('published'));
}
$query->orderBy('created_at DESC');
return $query;
}
示例3: addNameColumnQuery
protected function addNameColumnQuery(Doctrine_Query $query, $value)
{
if (!empty($value)) {
if (is_array($value)) {
foreach ($value as $v) {
$query->addWhere('name LIKE ?', '%' . $v . '%');
}
} else {
if (!empty($value)) {
$query->addWhere('name LIKE ?', '%' . $values . '%');
}
}
}
}
示例4: getSetting
/**
* getSetting
* pulls the sfSetting object for a given setting
*
* @param string $setting
* @static
* @access public
* @return object sfSetting
*/
static function getSetting($setting)
{
if (!is_string($setting) || empty($setting)) {
return 0;
}
// If all the settings have been requested, there's no need to check for
// individuals. This avoids additional queries later on.
if (sfContext::getInstance()->getRequest()->hasAttribute('AllsfSettings')) {
$settings = sfContext::getInstance()->getRequest()->getAttribute('AllsfSettings');
} else {
$settings = sfContext::getInstance()->getRequest()->getAttribute('sfSettings');
}
if (isset($settings[$setting])) {
$obj = $settings[$setting];
return $obj;
} else {
// Setting was not pre-loaded via ->load() but we'll be nice and retrieve
// the setting anyhow:
$query = new Doctrine_Query();
$query->addSelect("s.*");
$query->addFrom("sfSetting s");
$query->addWhere("s.name = :name", array(":name" => $setting));
if ($obj = $query->limit(1)->execute()->getFirst()) {
// Store this setting in memory for later retrieval to avoid a second
// query for the same setting:
$settings[$obj->getName()] = $obj;
sfContext::getInstance()->getRequest()->setAttribute('sfSettings', $settings);
// return it:
return $obj;
} else {
return 0;
}
}
}
示例5: hookWhere
/**
* hookWhere
* builds DQL query where part from given parameter array
*
* @param array $params an associative array containing field
* names and their values
* @return boolean whether or not the hooking was
*/
public function hookWhere($params)
{
if (!is_array($params)) {
return false;
}
foreach ($params as $name => $value) {
if ($value === '' || $value === '-') {
continue;
}
$e = explode('.', $name);
if (count($e) == 2) {
list($alias, $column) = $e;
$map = $this->query->getAliasDeclaration($alias);
$table = $map['table'];
if (!$table) {
throw new Doctrine_Exception('Unknown alias ' . $alias);
}
if ($def = $table->getDefinitionOf($column)) {
$def[0] = gettype($value);
if (isset($this->typeParsers[$def[0]])) {
$name = $this->typeParsers[$def[0]];
$parser = new $name();
}
$parser->parse($alias, $column, $value);
$this->query->addWhere($parser->getCondition(), $parser->getParams());
}
}
}
return true;
}
示例6: addUpcoming
public function addUpcoming(Doctrine_Query $q, $limit = null)
{
$q->orderBy('start_date');
$q->addWhere('DATE(start_date) >= DATE(NOW())');
if (!is_null($limit)) {
$q->limit($limit);
}
}
示例7: addNameColumnQuery
protected function addNameColumnQuery(Doctrine_Query $query, $field, $values)
{
$fieldName = $this->getFieldName($field);
if (is_array($values)) {
foreach ($values as $value) {
$query->addWhere('r.' . $fieldName . ' LIKE ?', '%' . $value . '%');
}
}
}
示例8: filterScope
/**
*
* @param Doctrine_Query $query
* @param sfUser $user
* @param type $alias
* @return Doctrine_Query
*/
public function filterScope(Doctrine_Query $query, sfUser $user, $alias = 'l')
{
$where = "{$alias}.location_scope_id = 5";
if (!$user->isAnonymous()) {
$uniq = self::$uniq++;
$where .= "\r\n or {$alias}.location_scope_id = 1\r\n or {$alias}.location_scope_id = 3\r\n or {$alias}.created_by = " . $user->getProfile()->id . "\r\n or {$alias}.created_by in (SELECT fa{$uniq}.accepter_id FROM friend fa{$uniq} WHERE fa{$uniq}.accepted = 1 and fa{$uniq}.requester_id = " . $user->getProfile()->id . ")\r\n or {$alias}.created_by in (SELECT fr{$uniq}.requester_id FROM friend fr{$uniq} WHERE fr{$uniq}.accepted = 1 and fr{$uniq}.accepter_id = " . $user->getProfile()->id . ")";
}
$query->addWhere($where);
return $query;
}
示例9: addUsernameColumnQuery
/**
* DOCUMENT ME
* @param Doctrine_Query $query
* @param mixed $field
* @param mixed $value
* @return mixed
*/
public function addUsernameColumnQuery(Doctrine_Query $query, $field, $value)
{
// You get an associative array with an sfWidgetFormFilterInput
if (!isset($value['text']) || !strlen($value['text'])) {
return;
}
$like = '%' . $value['text'] . '%';
$r = $query->getRootAlias();
$query->addWhere("({$r}.username LIKE ?) OR concat({$r}.first_name, {$r}.last_name) LIKE ?", array($like, $like));
}
示例10: withOwnerCheck
/**
* Проверить, что выборка принадлежит текущему авторизованному пользователю
*
* @param Doctrine_Query $q
* @param string $ownerColumn
* @return Doctrine_Query
*/
public function withOwnerCheck(Doctrine_Query $q, $ownerColumn = 'user_id')
{
$user = sfContext::getInstance()->getUser();
if ($user->isAuthenticated()) {
$userId = $user->getGuardUser()->getId();
} else {
$userId = 0;
}
$rootAlias = $q->getRootAlias();
$q->addWhere("{$rootAlias}.{$ownerColumn} = ?", $userId);
return $q;
}
示例11: fetchDetail
/**
* Get a record detail based the current query
*
* <code>
* $where = array(
* array('columnName' => 'searchValue')
* )
* </code>
*
* @param array $where
* @return array
*/
public function fetchDetail(array $where)
{
/**
* Remove these since we are trying to retrieve
* a specific row
*/
$this->_query->removeDqlQueryPart('limit')->removeDqlQueryPart('offset');
foreach ($where as $column => $value) {
$this->_query->addWhere($column . ' = ?', $value);
}
return $this->execute();
}
示例12: buildQuery
function buildQuery(Doctrine_Query $query)
{
$query->orderBy('swBlogComment.created_at ASC');
$query->leftJoin('swBlogComment.swBlogPost');
if ($this->getValue('moderated') == -2) {
$query->whereIn('swBlogComment.moderated', array(swBlogComment::MODERATED_NONE, swBlogComment::MODERATED_OK));
}
if ($this->getValue('moderated') == -1) {
$query->whereIn('swBlogComment.moderated', array(swBlogComment::MODERATED_NONE));
}
if ($this->getValue('moderated') == -3) {
$query->whereIn('swBlogComment.moderated', array(swBlogComment::MODERATED_KO, swBlogComment::MODERATED_OK));
}
if ($this->getValue('moderated') == 1) {
$query->whereIn('swBlogComment.moderated', array(swBlogComment::MODERATED_OK));
}
if ($this->getValue('moderated') === 0) {
$query->whereIn('swBlogComment.moderated', array(swBlogComment::MODERATED_KO));
}
if (is_numeric($this->getValue('post_id'))) {
$query->addWhere('swBlogComment.post_id = ?', $this->getValue('post_id'));
}
return $query;
}
示例13: query_may_write
/**
* Write - owner
*
* @param Doctrine_Query $q
* @param User $u
* @param string $alias (optional)
*/
public static function query_may_write($q, $u, $alias = null)
{
if ($u->is_system()) {
return;
}
$a = $alias ? "{$alias}." : "";
$q->addWhere("{$a}bin_user_id = ?", $u->user_id);
}
示例14: addBooleanQuery
protected function addBooleanQuery(Doctrine_Query $query, $field, $value)
{
$fieldName = $this->getFieldName($field);
$query->addWhere(sprintf('%s.%s = ?', $this->getRootAlias($query, $fieldName), $fieldName), $value);
}
示例15: modifyImpl
/**
* @access private
*
* @author Jannis Moßhammer <jannis.mosshammer@netways.de>
**/
protected function modifyImpl(Doctrine_Query &$o)
{
$o->setAliasDefs($this->mainAlias, $this->aliasDefs);
$o->setDefaultJoinType($this->defaultJoinType);
foreach ($this->fields as $field) {
$o->addSelect($field);
}
$o->distinct($this->isDistinct());
$o->from($this->target . " " . $this->mainAlias);
foreach ($this->staticWhereConditions as $cond) {
if (isset($cond[1]) && $cond[1] != null) {
$o->addWhere($cond[0], $cond[1]);
} else {
$o->addWhere($cond[0]);
}
}
}