本文整理汇总了PHP中Nette\Database\Table\Selection类的典型用法代码示例。如果您正苦于以下问题:PHP Selection类的具体用法?PHP Selection怎么用?PHP Selection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Selection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: appendLimit
static function appendLimit(Nette\Database\Table\Selection &$query, $limit = NULL, $offset = NULL)
{
if (!is_null($limit)) {
$query->limit($limit, $offset);
}
return $query;
}
示例2: filterSection
/**
* @param Selection $context
* @param int $sectionId
* @param string $via [optional]
* @return Selection
*/
public function filterSection(Selection $context, $sectionId, $via = '')
{
$context->alias($this->sectionTableName, 'alternate_section');
$filterFactory = new Filter\Factory($this->sectionTableName);
$nFilter = $filterFactory->createN($context);
$nFilter->setup('id', $sectionId)->via("{$via}:page_has_section");
$nFilter->setup('id', $sectionId, 'alternate_section')->via($via);
return $nFilter->build();
}
示例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: apply
/**
* @param \Nette\Database\Table\Selection $selection
* @param string|Callable $callback
*/
private function apply(Selection $selection, $callback)
{
if (!$callback) {
return;
}
if (is_string($callback)) {
$selection->select($callback);
} else {
$callback($selection);
}
}
示例5: getData
/**
* @param int $limit
* @param int $offset
* @return array
*/
public function getData($limit = NULL, $offset = NULL)
{
if ($limit !== NULL) {
$this->source->limit($limit, $offset);
}
return $this->source->fetchAll();
}
示例6: render
public function render()
{
$this->_calendarMonthData->rewind();
$this->template->data = $this->_calendarMonthData;
$this->template->setFile(__DIR__ . '/Month.latte');
$this->template->render();
}
示例7: process
/**
* Default form handler
*/
public function process()
{
/** @var ArrayHash $values */
$values = $this->values;
try {
$this->onBeforeProcess($this, $values);
if (isset($values->id)) {
$this->onBeforeUpdate($this, $values);
$arr = (array) $values;
unset($arr['id']);
$row = $this->selection->wherePrimary($values->id)->fetch();
$row->update($arr);
$this->onAfterUpdate($row, $this, $values);
} else {
$this->onBeforeInsert($this, $values);
$row = $this->selection->insert($values);
$this->onAfterInsert($row, $this, $values);
}
$this->onAfterProcess($row, $this, $values);
} catch (\PDOException $e) {
$this->addError($e->getMessage());
dump($e);
Debugger::log($e);
}
}
示例8: 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);
}
}
示例9: 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;
}
示例10: setTexts
/** Nastavenie textov
* @param array $texts
* @return \App\FrontModule\Components\Clanky\AktualneClankyControl
*/
public function setTexts($texts)
{
$this->texts = array_merge($this->texts, $texts);
return $this;
}
/** Nastavenie cesty k titulnemu obrazku clanku
示例11: render
if (is_int($pocet) && $pocet > 1) {
$this->pocet = $pocet;
}
}
/** Zakladny render */
public function render()
{
$this->template->setFile(__DIR__ . '/Last.latte');
$this->template->h3 = 'Posledných ' . $this->pocet . ' prihlásení';
$this->template->last = $this->last->order('prihlasenie_datum DESC')->limit($this->pocet);
$this->template->render();
示例12: 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);
}
示例13: buildJoins
protected function buildJoins($val, $inner = FALSE)
{
$driver = $this->selection->getConnection()->getSupplementalDriver();
$reflection = $this->selection->getConnection()->getDatabaseReflection();
$joins = array();
preg_match_all('~\\b([a-z][\\w.:]*[.:])([a-z]\\w*|\\*)(\\s+IS\\b|\\s*<=>)?~i', $val, $matches);
foreach ($matches[1] as $names) {
$parent = $this->selection->getName();
if ($names !== "{$parent}.") {
// case-sensitive
preg_match_all('~\\b([a-z][\\w]*|\\*)([.:])~i', $names, $matches, PREG_SET_ORDER);
foreach ($matches as $match) {
list(, $name, $delimiter) = $match;
if ($delimiter === ':') {
list($table, $primary) = $reflection->getHasManyReference($parent, $name);
$column = $reflection->getPrimary($parent);
} else {
list($table, $column) = $reflection->getBelongsToReference($parent, $name);
$primary = $reflection->getPrimary($table);
}
$joins[$name] = ' ' . (!isset($joins[$name]) && $inner && !isset($match[3]) ? 'INNER' : 'LEFT') . ' JOIN ' . $driver->delimite($table) . ($table !== $name ? ' AS ' . $driver->delimite($name) : '') . ' ON ' . $driver->delimite($parent) . '.' . $driver->delimite($column) . ' = ' . $driver->delimite($name) . '.' . $driver->delimite($primary);
$parent = $name;
}
}
}
return $joins;
}
示例14: update
public function update($data, $forceRegenerateTimes = FALSE)
{
parent::update($data);
if ($forceRegenerateTimes || rand(0, 100) < 10) {
$this->generateAllTimes();
}
}
示例15: access
public function access($key, $delete = FALSE)
{
if ($this->table->connection->getCache() && !isset($this->modified[$key]) && $this->table->access($key, $delete)) {
$id = isset($this->data[$this->table->primary]) ? $this->data[$this->table->primary] : $this->data;
$this->data = $this->table[$id]->data;
}
}