Source

cruge / models / data / CrugeFieldValue.php

Diff from to

File models/data/CrugeFieldValue.php

 	public static function loadModelBy($iduser,$idfield){
 		return self::model()->findByAttributes(array('iduser'=>$iduser,'idfield'=>$idfield));
 	}
+
+	/**
+	 * loadByValue 
+	 *	busca un FieldValue por su valor y campo 
+	 * @param mixed $idfield 
+	 * @param mixed $value 
+	 * @static
+	 * @access public
+	 * @return instancia de CrugeFieldValue o null
+	 */
+	public static function loadByValue($idfield, $value){
+		// para ocasiones podria ser util un indice en el modelo 
+		// para esta busqueda.
+		$filtro = array(
+			":idfield" => $idfield,
+			":value" => $value
+		);
+		foreach(self::model()->findAll(array(
+            	"condition" =>
+	               	"idfield = :idfield AND value = :value",
+	               	"params" => $filtro
+        	)) as $obj)
+				return $obj;
+		return null;
+	}
 	
 	/**
 		devuelve un array de objetos que implementan a ICrugeFieldValue