本文整理汇总了PHP中Condition类的典型用法代码示例。如果您正苦于以下问题:PHP Condition类的具体用法?PHP Condition怎么用?PHP Condition使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Condition类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:RedaB,项目名称:PHPBase,代码行数:27,代码来源:ModeleBase.class.php
示例2: testValidateOperator
function testValidateOperator()
{
$c = new Condition();
$c->add('foo', 'bar', 'SQL injection!');
$this->setExpectedException('InvalidArgumentException');
$stmnt = $c->getQueryStatement();
$stmnt->setConnection(DBManager::getConnection());
}
开发者ID:abcarroll,项目名称:DABL,代码行数:8,代码来源:ConditionTest.php
示例3: getTelefones
public function getTelefones()
{
$condition = new Condition();
$condition->addFilter("pessoa_id = '" . $this->id . "'");
$telefoneTable = new TelefoneTable();
$telefones = $telefoneTable->get($condition);
return $telefones;
}
开发者ID:BGCX067,项目名称:facsis-hg-to-git,代码行数:8,代码来源:Helper.class.php
示例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]));
}
开发者ID:xp-forge,项目名称:assert,代码行数:7,代码来源:StringAssertions.class.php
示例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';
}
}
开发者ID:Nr90,项目名称:kennissysteem,代码行数:16,代码来源:formatter.php
示例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;
}
}
开发者ID:nattaphat,项目名称:cuse2,代码行数:12,代码来源:Condition.php
示例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));
}
开发者ID:fkali,项目名称:yupp,代码行数:8,代码来源:apps.helloWorld.controllers.PersonaController.class.php
示例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'));
}
开发者ID:adriacidre,项目名称:gamereuse,代码行数:8,代码来源:GameController.php
示例9: removeCondition
public function removeCondition(Condition $condition = null)
{
if ($condition) {
if ($this->condition) {
$this->condition->removeCondition($condition);
}
} else {
$this->condition = null;
}
}
开发者ID:saiber,项目名称:www,代码行数:10,代码来源:ARFilter.php
示例10: _argToCondition
protected function _argToCondition($arg)
{
if (!$arg instanceof Condition) {
$arg = Condition::create($arg);
if ($this->_prefix) {
$arg->setPrefix($this->_prefix);
}
}
return $arg;
}
开发者ID:Ekhvalov,项目名称:recordsman,代码行数:10,代码来源:Condition.php
示例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);
}
}
开发者ID:tatarko,项目名称:dibi-active-record,代码行数:15,代码来源:Join.php
示例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);
}
开发者ID:cujan,项目名称:atlashornin,代码行数:17,代码来源:DateRange.php
示例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) {
}
}
开发者ID:NinjaKC,项目名称:MySQL-Query-Builder,代码行数:21,代码来源:OtherTest.php
示例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;
}
}
开发者ID:kimkucheol,项目名称:xe-core,代码行数:21,代码来源:ConditionWithoutArgument.class.php
示例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;
}
开发者ID:Kaliver,项目名称:grido,代码行数:19,代码来源:Number.php
示例16: __set
public function __set($name, $value)
{
if ($value instanceof PersistenceModel) {
$value = ColumnManager::getColumn();
} else {
if (is_string($value)) {
$value = preg_replace("/(.)'(.)/i", '$1\\\'$2', $value);
}
}
if (Condition::is_operator($name)) {
self::addCondition(Condition::getInstance($name, $this->relation_name, $value));
} else {
$fullname = ($this->relation ? "{$this->relation}." : "") . ($this->name ? "{$this->name}." : "") . $name;
self::addCondition(Condition::__equ__($fullname, $value));
}
}
开发者ID:exildev,项目名称:corvus,代码行数:16,代码来源:PersistenceModel.php
示例17: createSelectParams
public static function createSelectParams($condition = null, $order = null, $limit = null)
{
$sql = "";
if (!is_null($condition)) {
$sql .= " WHERE " . Condition::create($condition)->toSql();
} else {
$sql .= " WHERE 1";
}
if ($order) {
$sql .= " ORDER BY " . Helper::orderToSql($order);
}
if ($limit) {
$sql .= " LIMIT " . Helper::limitToSql($limit);
}
return $sql;
}
开发者ID:Ekhvalov,项目名称:recordsman,代码行数:16,代码来源:Helper.php
示例18: getTimeline
public static function getTimeline($user, $offset = 0, $max = 20)
{
if ($user == NULL) {
throw new Exception('user is null');
}
// Messages belonging to me or the users I follow
$_or = Condition::_OR()->add(Condition::EQ(self::TABLE, 'createdBy_id', $user->getId()));
// I want to see my messages also
$following = $user->getFollowing();
foreach ($following as $otherUser) {
$_or->add(Condition::EQ(self::TABLE, 'createdBy_id', $otherUser->getId()));
}
// Paginated search
// Messages ordered by createdOn, first the last messages
$list = Message::findBy($_or, new ArrayObject(array('sort' => 'createdOn', 'dir' => 'desc', 'offset' => $offset, 'max' => $max)));
return $list;
}
开发者ID:fkali,项目名称:yupp,代码行数:17,代码来源:twitter.model.Message.class.php
示例19: _select
public static function _select($condition = null, $order = null, $limit = null)
{
if (is_null(self::$_preloaded)) {
self::$_preloaded = parent::_select();
}
//TODO: $order & $limit processing
if (is_null($condition)) {
return self::$_preloaded;
}
$condition = Condition::create($condition);
$resultSet = [];
foreach (self::$_preloaded as $entry) {
if ($condition->test($entry)) {
$resultSet[] = $entry;
}
}
return $resultSet;
}
开发者ID:Ekhvalov,项目名称:recordsman,代码行数:18,代码来源:TPreload.php
示例20: login
/**
* @param string username
* @param string password
* @param boolean remember
*/
public static function login($username, $password)
{
if (empty($username) || empty($password)) {
return self::LOGIN_ERR_INCOMPLETE;
}
$cond = Condition::_AND()->add(Condition::EQ(self::TABLE, 'username', $username))->add(Condition::EQ(self::TABLE, 'password', $password));
$list = TUser::findBy($cond, new ArrayObject());
if (count($list) == 0) {
return self::LOGIN_ERR_FAILED;
}
$user = $list[0];
// Uusario logueado queda en session
YuppSession::set('_twitter_user', $user);
$user->save();
// TODO: check 4 errors
// TODO: se deberia llevar log de la IP+userid+fecha
// Se podria hacer un archivo de log en disco por cada user id y poner fechas con ips nomas
return self::LOGIN_ERR_SUCCESS;
}
开发者ID:fkali,项目名称:yupp,代码行数:24,代码来源:twitter.model.TUser.class.php
注:本文中的Condition类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论