当前位置: 首页>>代码示例>>PHP>>正文


PHP Selection::where方法代码示例

本文整理汇总了PHP中Nette\Database\Table\Selection::where方法的典型用法代码示例。如果您正苦于以下问题:PHP Selection::where方法的具体用法?PHP Selection::where怎么用?PHP Selection::where使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Nette\Database\Table\Selection的用法示例。


在下文中一共展示了Selection::where方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: filter

 /**
  * Filter data
  * @param array $filter
  */
 public function filter(array $filter)
 {
     foreach ($filter as $key => $value) {
         $value = is_numeric($value) ? $value : '%' . $value . '%';
         $this->table->where($key . ' LIKE ?', $value);
     }
 }
开发者ID:drahak,项目名称:tables,代码行数:11,代码来源:DefaultDataSource.php

示例2: validate

 public function validate(BaseControl $control)
 {
     $condition[$control->name] = $control->value;
     if ($this->id) {
         $condition['id!='] = $this->id;
     }
     return $this->selection->where($condition)->count() ? FALSE : TRUE;
 }
开发者ID:04EO,项目名称:TrainingTaskNette,代码行数:8,代码来源:UniqueValidator.php

示例3: setModel

 /**
  * Nastavi model
  * @param Nette\Database\Table\Selection
  */
 public function setModel(\Nette\Database\Table\Selection $model)
 {
     if (isset($this->filter['email']) && $this->filter['email'] != '') {
         $model->where('adress REGEXP ?', $this->filter['email']);
     }
     if (isset($this->filter['subject']) && $this->filter['subject'] != '') {
         $model->where('subject REGEXP ?', $this->filter['subject']);
     }
     $this->model = $model;
 }
开发者ID:vsek,项目名称:base,代码行数:14,代码来源:GridEmailLog.php

示例4: getProdukt

 /** Nacitanie udajov o produkte
  * @param int $id Id produktu
  * @param int $id_lang Id jazyka
  * @return array|FALSE
  */
 public function getProdukt($id, $id_lang = 1)
 {
     $hlavne_menu_lang = $this->hlavne_menu_lang->where(array("id_hlavne_menu" => $id, "id_lang" => $id_lang));
     if ($hlavne_menu_lang === FALSE) {
         return FALSE;
     }
     $produkt = $this->find($hlavne_menu_lang->hlavne_menu->clanok);
     if ($produkt === FALSE) {
         return FALSE;
     }
     return array("hlavne_menu_lang" => $hlavne_menu_lang, "produkt" => $produkt);
 }
开发者ID:petak23,项目名称:echo-msz,代码行数:17,代码来源:Produkt_lang.php

示例5: search

 public function search($q)
 {
     $query = "";
     $count = count($this->columns);
     $i = 0;
     $phldrs = array();
     foreach ($this->columns as $column) {
         $query .= new \Nette\Database\SqlLiteral($column . " " . $this->method . " ?");
         $phldrs[] = str_replace($this->placeholder, $q, $this->mask);
         if ($i < $count - 1) {
             $query .= " OR ";
         }
         $i++;
     }
     return $this->model->where($query, $phldrs);
 }
开发者ID:sg3tester,项目名称:songator,代码行数:16,代码来源:Searcher.php

示例6: filter

 /**
  * Add filtering onto specified column
  *
  * @param string column name
  * @param string filter
  * @param string|array operation mode
  * @param string chain type (if third argument is array)
  * @return IDataSource (fluent)
  * @throws \Nette\InvalidArgumentException
  */
 public function filter($column, $operation = IDataSource::EQUAL, $value = NULL, $chainType = NULL)
 {
     if (!$this->hasColumn($column)) {
         throw new \Nette\InvalidArgumentException('Trying to filter data source by unknown column.');
     }
     if (is_array($operation)) {
         if ($chainType !== self::CHAIN_AND && $chainType !== self::CHAIN_OR) {
             throw new \Nette\InvalidArgumentException('Invalid chain operation type.');
         }
     } else {
         $operation = [$operation];
     }
     if (empty($operation)) {
         throw new \Nette\InvalidArgumentException('Operation cannot be empty.');
     }
     $conds = $values = [];
     foreach ($operation as $o) {
         $this->validateFilterOperation($o);
         $c = $this->mapping[$column] . " {$o}";
         if ($o !== self::IS_NULL && $o !== self::IS_NOT_NULL) {
             $c .= ' ?';
             $values[] = $o === self::LIKE || $o === self::NOT_LIKE ? DataSources\Utils\WildcardHelper::formatLikeStatementWildcards($value) : $value;
         }
         $conds[] = $c;
     }
     $conds = implode(" ( {$chainType} ) ", $conds);
     // "(cond1) OR (cond2) ..."  -- outer braces missing for now
     $this->selection->where("( {$conds} )", $values);
     return $this;
 }
开发者ID:lohini,项目名称:cf,代码行数:40,代码来源:DB.php

示例7: filter

 /**
  * Filter IT!
  * @param string $flags
  */
 public function filter($flags)
 {
     //One and main logic!
     $columns = array();
     foreach (str_split($flags) as $char) {
         if (!array_key_exists($char, $this->flags)) {
             throw new \Nette\InvalidArgumentException("Unrecognized flag '{$char}'", 3315);
         }
         $flag = $this->flags[$char];
         if (!is_array($flag)) {
             $arr = array();
             $arr["column"] = $flag;
             $arr["by"] = " = 1";
             $columns[] = $arr;
         } else {
             $columns[] = $flag;
         }
     }
     return $this->model->where($this->getQueryString($columns));
 }
开发者ID:sg3tester,项目名称:songator,代码行数:24,代码来源:FlagFilter.php

示例8: appendFilter

 static function appendFilter(Nette\Database\Table\Selection &$query, $filter = NULL, array $defaultFilterType = [], array $filterTranslate = [])
 {
     if (!is_null($filter)) {
         if (isset($filter[ABaseList::STRICT])) {
             $query->where($filter[ABaseList::STRICT]);
             unset($filter[ABaseList::STRICT]);
         }
         foreach ($filter as $k => $v) {
             $key = $k;
             if (array_key_exists($k, $filterTranslate)) {
                 $key = $filterTranslate[$k];
             }
             if (array_key_exists($k, $defaultFilterType)) {
                 switch ($defaultFilterType[$k]) {
                     case '<':
                         $query->where($key . ' < ?', $v);
                         break;
                     case '<=':
                         $query->where($key . ' <= ?', $v);
                         break;
                     case '<=date':
                         $query->where($key . ' < ? + INTERVAL 1 DAY', $v);
                         break;
                     case '>':
                         $query->where($key . ' > ?', $v);
                         break;
                     case '>=':
                         $query->where($key . ' >= ?', $v);
                         break;
                     case '=':
                         $query->where($key . ' = ?', $v);
                         break;
                     default:
                         throw new Trejjam\Utils\LogicException('Unknown filter type ' . $defaultFilterType[$k]);
                 }
             } else {
                 $query->where([$key . ' LIKE' => '%' . $v . '%']);
             }
         }
     }
     return $query;
 }
开发者ID:trejjam,项目名称:utils,代码行数:42,代码来源:BaseQuery.php

示例9: __construct

 /**
  * @param Nette\Database\Table\Selection $dokumenty
  */
 public function __construct(Nette\Database\Table\Selection $dokumenty)
 {
     parent::__construct();
     //Najdem si len obrazky
     $this->dokumenty = $dokumenty->where("pripona", array("jpg", "png", "gif", "bmp"));
 }
开发者ID:petak23,项目名称:echo-msz,代码行数:9,代码来源:NahodnaFotka.php

示例10: getReferencedTable

 /**
  * Returns referenced row.
  * @param  string
  * @return ActiveRow or NULL if the row does not exist
  */
 public function getReferencedTable($name, &$column = NULL)
 {
     $column = $this->connection->databaseReflection->getReferencedColumn($name, $this->name);
     $referenced =& $this->referenced[$name];
     if ($referenced === NULL) {
         $keys = array();
         foreach ($this->rows as $row) {
             if ($row[$column] !== NULL) {
                 $keys[$row[$column]] = NULL;
             }
         }
         if ($keys) {
             $table = $this->connection->databaseReflection->getReferencedTable($name, $this->name);
             $referenced = new Selection($table, $this->connection);
             $referenced->where($table . '.' . $this->getPrimary($table), array_keys($keys));
         } else {
             $referenced = array();
         }
     }
     return $referenced;
 }
开发者ID:rostenkowski,项目名称:HttpPHPUnit,代码行数:26,代码来源:Selection.php

示例11: setModel

 public function setModel(\Nette\Database\Table\Selection $model)
 {
     parent::setModel($model->where('parent_id ?', null));
 }
开发者ID:vsek,项目名称:grid,代码行数:4,代码来源:GridTree.php

示例12: getReferencedTable

 /**
  * Returns referenced row.
  * @param  string
  * @param  string
  * @param  bool  checks if rows contains the same primary value relations
  * @return ActiveRow or NULL if the row does not exist
  */
 public function getReferencedTable($table, $column, $checkReferenceNewKeys = FALSE)
 {
     $referenced =& $this->referenced[$table][$column];
     if ($referenced === NULL || $checkReferenceNewKeys || $this->checkReferenceNewKeys) {
         $keys = array();
         foreach ($this->rows as $row) {
             if ($row[$column] === NULL) {
                 continue;
             }
             $key = $row[$column] instanceof ActiveRow ? $row[$column]->getPrimary() : $row[$column];
             $keys[$key] = TRUE;
         }
         if ($referenced !== NULL && $keys === array_keys($this->rows)) {
             $this->checkReferenceNewKeys = FALSE;
             return $referenced;
         }
         if ($keys) {
             $referenced = new Selection($table, $this->connection);
             $referenced->where($table . '.' . $referenced->primary, array_keys($keys));
         } else {
             $referenced = array();
         }
     }
     return $referenced;
 }
开发者ID:exesek,项目名称:nette20login,代码行数:32,代码来源:Selection.php

示例13: applyFilterSelect

 /**
  * Filter by select value
  * @param  Filter\FilterSelect $filter
  * @return void
  */
 public function applyFilterSelect(Filter\FilterSelect $filter)
 {
     $this->data_source->where($filter->getCondition());
 }
开发者ID:ublaboo,项目名称:datagrid,代码行数:9,代码来源:NetteDatabaseTableDataSource.php

示例14: addCondition

 /**
  * @param $condition
  * @return self
  */
 public function addCondition($condition)
 {
     $this->selection->where($condition);
     return $this;
 }
开发者ID:jkrecek,项目名称:nette-database-model,代码行数:9,代码来源:StoredCollection.php

示例15: filterSearch

 /**
  * Hleda vyraz ve sloupci.
  * @param \Nette\Database\Table\Selection $selection
  * @param string $column
  * @param string $word
  * @param string $via
  * @return \Nette\Database\Table\Selection
  */
 public function filterSearch(Selection $selection, $column, $word, $via = '')
 {
     return $selection->where("? LIKE ?", new \Nette\Database\SqlLiteral($column), "%{$word}%");
 }
开发者ID:kysela-petr,项目名称:generator-kysela,代码行数:12,代码来源:ISFilter.php


注:本文中的Nette\Database\Table\Selection::where方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。