本文整理汇总了PHP中Condition::EQA方法的典型用法代码示例。如果您正苦于以下问题:PHP Condition::EQA方法的具体用法?PHP Condition::EQA怎么用?PHP Condition::EQA使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Condition
的用法示例。
在下文中一共展示了Condition::EQA方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Query
<pre>
<?php
include_once "core.db.criteria2.Condition.class.php";
include_once "core.db.criteria2.ComplexCondition.class.php";
include_once "core.db.criteria2.CompareCondition.class.php";
include_once "core.db.criteria2.BinaryInfixCondition.class.php";
include_once "core.db.criteria2.UnaryPrefixCondition.class.php";
include_once "core.db.criteria2.Query.class.php";
include_once "core.db.criteria2.Select.class.php";
include_once "../core.db.DatabaseMySQL.class.php";
$q = new Query();
$q->addFrom('Persona', 'p')->addFrom('Empleado', 'e')->setCondition(Condition::_AND()->add(Condition::EQ('p', "nombre", "Carlos"))->add(Condition::GT('p', "edad", 5))->add(Condition::EQA('p', "nombre", 'p', "nombre2")));
$db = new DatabaseMySQL();
echo $db->evaluateQuery($q);
//echo Condition::EQ("per", "nombre", "Carlox")->evaluate();
//echo Condition::EQA("per", "nombre", "per", "nombre2")->evaluate();
/*
$sel = new Select();
$sel->addProjection("per", "name");
$sel->addProjection("per", "age");
$sel->addAvg("per", "age");
echo $sel->evaluate();
*/
$q = new Query();
$q->addAggregation(SelectAggregation::AGTN_DISTINTC, 'datos', 'nombre')->addFrom('Persona', 'datos')->setCondition(Condition::GT('p', "edad", 5));
echo $db->evaluateQuery($q);
?>
</pre>
示例2: findHasManyReverse
/**
* Devuelve una lista de $searchClass, tal que:
* 1. $searchClass tiene un atributo hasMany $hasManyAttr a la clase $byClass
* 2. $searchClass tiene una instancia de $byClass en $hasManyAttr con $byId
*/
public function findHasManyReverse($searchClass, $hasManyAttr, $byClass, $byId)
{
$sins = new $searchClass(array(), true);
// PHP 5.3
if (!$sins->hasAttribute($hasManyAttr)) {
throw new Exception("El atributo hasMany {$hasManyAttr} no existe");
}
// tabla de join
$relins = new $byClass(array(), true);
$joinTableName = YuppConventions::relTableName($sins, $hasManyAttr, $relins);
// tabla de esta clase
$objTableName = YuppConventions::tableName($sins);
// quiero owner_id de la tabla de join, por byId
// luego hacer join con la tabla de $this
//$cond = Condition::EQ($joinTableName, "byId", $byId);
// similar PM.get_many_assoc_lazy
YuppLoader::load('core.db.criteria2', 'Query');
$q = new Query();
$q->addFrom($joinTableName, 'ref')->addFrom($objTableName, 'obj')->addProjection('obj', '*')->setCondition(Condition::_AND()->add(Condition::EQA('obj', 'id', 'ref', 'owner_id'))->add(Condition::EQ('ref', 'ref_id', $byId)));
$data = $this->findByQuery($q);
// PM 760
$result = array();
foreach ($data as $many_attrValues) {
if ($many_attrValues['class'] === $byClass) {
//echo " la clase es la misma que la declarada<br/>";
$rel_obj = $this->createObjectFromData($byClass, $many_attrValues);
} else {
//echo " la clase NO es la misma que la declarada<br/>";
$rel_obj = $this->get_mti_object_byData($byClass, $many_attrValues);
}
$result[] = $rel_obj;
}
return $result;
}