本文整理汇总了PHP中Condition类的典型用法代码示例。如果您正苦于以下问题:PHP Condition类的具体用法?PHP Condition怎么用?PHP Condition使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Condition类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: obtenirTout
public static function obtenirTout(Condition $conditions = NULL, $offset = 0, $limite = NULL)
{
$listeRecords = ORM::forTable(self::nomTable());
// Prise en compte d'éventuelles conditions
if ($conditions !== NULL) {
$listeRecords->whereRaw($conditions->generer(), $conditions->listeValeurs());
}
// Pris en compte de l'éventuel limite
if ($limite !== NULL) {
$listeRecords->limit($limite);
}
// Prise en compte de l'éventuel offset
$listeRecords->offset($offset);
// Récupération des résultats
$listeRecords = $listeRecords->findMany();
$listeElements = array();
// On récupère le nom de la classe instanciée pour pouvoir en retourner les objets
$nomClasse = get_called_class();
foreach ($listeRecords as $record) {
$objet = new $nomClasse();
// Hydration de l'objet
$objet->setRecord($record);
// Ajout dans la liste des résultats
$listeElements[] = $objet;
}
return $listeElements;
}
示例2: testValidateOperator
function testValidateOperator()
{
$c = new Condition();
$c->add('foo', 'bar', 'SQL injection!');
$this->setExpectedException('InvalidArgumentException');
$stmnt = $c->getQueryStatement();
$stmnt->setConnection(DBManager::getConnection());
}
示例3: getTelefones
public function getTelefones()
{
$condition = new Condition();
$condition->addFilter("pessoa_id = '" . $this->id . "'");
$telefoneTable = new TelefoneTable();
$telefones = $telefoneTable->get($condition);
return $telefones;
}
示例4: doesNotContain
public function doesNotContain($string)
{
$rep = Condition::stringOf($string);
return $this->isNot(new Match(function ($value) use($string) {
return false !== strpos($value, $string);
}, ['%s does not contain ' . $rep, '%s contains ' . $rep]));
}
示例5: evaluatedValue
protected function evaluatedValue(Condition $condition)
{
if (!$this->state) {
return 'unknown';
}
$value = $condition->evaluate($this->state);
if ($value instanceof Yes) {
return 'true';
} elseif ($value instanceof No) {
return 'false';
} elseif ($value instanceof Maybe) {
return 'maybe';
} else {
return 'undefined';
}
}
示例6: checkCondition
/**
* [checkCondition description]
* @param [type] $cond [description]
* @return [type] [description]
*/
public function checkCondition($cond)
{
$rs = Condition::where('cond_name', '=', $cond)->count();
if (isset($rs)) {
return $rs >= 1 ? false : true;
}
}
示例7: queryAction
public function queryAction()
{
$q = new Query();
$q->addAggregation(SelectAggregation::AGTN_DISTINTC, 'p', 'nombre')->addFrom('hello_world_persona', 'p')->setCondition(Condition::GT('p', "edad", 25));
$pm = PersistentManager::getInstance();
$result = $pm->findByQuery($q);
return $this->renderString(print_r($result, true));
}
示例8: getView
public function getView($slug)
{
$game = $this->getModelFromSlug($slug);
$products = $game->products()->orderBy('created_at', 'DESC')->get();
$platforms = Platform::all();
$conditions = Condition::all();
return View::make('site/game/view_game', compact('game', 'products', 'platforms', 'conditions'));
}
示例9: removeCondition
public function removeCondition(Condition $condition = null)
{
if ($condition) {
if ($this->condition) {
$this->condition->removeCondition($condition);
}
} else {
$this->condition = null;
}
}
示例10: _argToCondition
protected function _argToCondition($arg)
{
if (!$arg instanceof Condition) {
$arg = Condition::create($arg);
if ($this->_prefix) {
$arg->setPrefix($this->_prefix);
}
}
return $arg;
}
示例11: applyOn
/**
* Apply this JOIN statement on given query
* @param array $query Query to apply JOIN on
* @return void
*/
public function applyOn(array &$query)
{
$query[] = sprintf('%s %%n %%n', $this->type);
$query[] = $this->table;
$query[] = $this->name ?: $this->table;
if (!empty($this->conditions)) {
$query[] = 'ON';
Condition::applyListOn($query, $this->conditions);
}
}
示例12: __getCondition
/**
* @param string $value
* @return Condition
* @throws \Exception
* @internal
*/
public function __getCondition($value)
{
if ($this->where === NULL && is_string($this->condition)) {
list(, $from, $to) = \Nette\Utils\Strings::match($value, $this->mask);
$from = \DateTime::createFromFormat($this->dateFormatInput, trim($from));
$to = \DateTime::createFromFormat($this->dateFormatInput, trim($to));
$values = $from && $to ? array($from->format($this->dateFormatOutput), $to->format($this->dateFormatOutput)) : NULL;
return $values ? Condition::setup($this->getColumn(), $this->condition, $values) : Condition::setupEmpty();
}
return parent::__getCondition($value);
}
示例13: testCondition
public function testCondition()
{
$params = array();
$f = new Field('test');
$arr = array(1, 2, 3, 4, 5);
$c = new Condition('in', $f, $arr);
$this->assertEquals('`t0`.`test` IN (1, 2, 3, 4, 5)', $c->getSql($params));
$this->assertEquals('in', $c->getComparison());
$this->assertEquals(var_export($f, true), var_export($c->getLeft(), true));
$this->assertEquals(var_export($arr, true), var_export($c->getRight(), true));
try {
$c = new Condition('in', new Field('test'), 'error');
$this->fail('second parameter shoud be array-only, but string passed');
} catch (InvalidArgumentException $e) {
}
try {
$c = new Condition('in', new Field('test'), array('a'));
$this->fail('second parameter shoud be array of integets, but array of strings passed');
} catch (InvalidArgumentException $e) {
}
}
示例14: ConditionWithoutArgument
/**
* constructor
* @param string $column_name
* @param mixed $argument
* @param string $operation
* @param string $pipe
* @return void
*/
function ConditionWithoutArgument($column_name, $argument, $operation, $pipe = "")
{
parent::Condition($column_name, $argument, $operation, $pipe);
$tmpArray = array('in' => 1, 'notin' => 1, 'not_in' => 1);
if (isset($tmpArray[$operation])) {
if (is_array($argument)) {
$argument = implode($argument, ',');
}
$this->_value = '(' . $argument . ')';
} else {
$this->_value = $argument;
}
}
示例15: __getCondition
/**
* @param string $value
* @return Condition|bool
* @throws \Exception
* @internal
*/
public function __getCondition($value)
{
$condition = parent::__getCondition($value);
if ($condition === NULL) {
$condition = Condition::setupEmpty();
if (preg_match('/(<>|[<|>]=?)?([-0-9,|.]+)/', $value, $matches)) {
$value = str_replace(',', '.', $matches[2]);
$operator = $matches[1] ? $matches[1] : '=';
$condition = Condition::setup($this->getColumn(), $operator . ' ?', $value);
}
}
return $condition;
}