Query Existing Result Set

One thing that I was exposed to in some .NET/MVC/C# development earlier this year was the ability to further query results returned from a query. [size="2"]So, for example, if I executed a query to request a listing of all products in a catalog I could use that variable containing the list in a subsequent query. [/size]

Depending on how this is implemented it could simplify source code and improve performance. One could store frequently used sets of data in cache and then run queries against them.

I’m pretty sure this isn’t currently implemented in CActiveRecord management, but I thought I’d check, just in case. If not, is it being considered for Yii 2.0? Has anyone developed an extension that implements the functionality?

Thanks in advance,


i dont know if yii have a functionality like that but i wonder if you can use database Views for that or not ?

Thank you, but I’m looking for something that can filter existing results so that I don’t have to make a trip back to the database server with another query, but can perform it in memory instead.

Also, as sort of a side note, I’m currently using MySQL and I’ve found that views are very slow compared to Postgres, which is what I have used in the past. I wouldn’t normally generalize about something like that, except that it has happened to me with several very different views.

this is a helpfull sidenote i m going to check it. thx.

i know this is not what exactly you are looking but it will help a little.

check that page i ll also copy paste under this post…


$criteria = new CDbCriteria;

$criteria->condition = 'group_id IN (1,3) OR subject_id IN (1,4,6,7)'

$relation_models = Relation::model()->findAll($criteria);

You could also use addInCondition :

$criteria->addInCondition('group_id', array('1','2'), 'OR');

$criteria->addInCondition('subject_id', array('1','4','6','7'), 'OR');

$relation_models = Relation::model()->findAll($criteria);

link where i get this answer is :

This might help, although not exactly what you were looking for: