當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Condition::EQA方法代碼示例

本文整理匯總了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>
開發者ID:fkali,項目名稱:yupp,代碼行數:29,代碼來源:QueryTest.php

示例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;
 }
開發者ID:fkali,項目名稱:yupp,代碼行數:39,代碼來源:core.persistent.PersistentManager.class.php


注:本文中的Condition::EQA方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。