本文整理汇总了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);
}
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
示例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;
}
示例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));
}
示例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;
}
示例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"));
}
示例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;
}
示例11: setModel
public function setModel(\Nette\Database\Table\Selection $model)
{
parent::setModel($model->where('parent_id ?', null));
}
示例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;
}
示例13: applyFilterSelect
/**
* Filter by select value
* @param Filter\FilterSelect $filter
* @return void
*/
public function applyFilterSelect(Filter\FilterSelect $filter)
{
$this->data_source->where($filter->getCondition());
}
示例14: addCondition
/**
* @param $condition
* @return self
*/
public function addCondition($condition)
{
$this->selection->where($condition);
return $this;
}
示例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}%");
}