[ome-devel] findObjects or obtainDBH for difficult queries

august august at develop.ment.org
Thu Mar 16 17:46:37 GMT 2006


> >Is this possible with findObjects?
> 
> Not the way its currently implemented - at least not in a single  
> query.  You could of course do it in 3 queries (actually, probably 9  
> in this case).
> 
> Another option is to slightly alter your datamodel by using references:
> CellType
> 	CellNumber integer (here you would put 1, 2 and 3 - if needed)
> 	CellType string (here you'd have "microglia", "ganglion", etc)
> 	TheTesting reference to Testing
> CellColor
> 	ColorNumber integer (1, 2, 3 again - if needed)
> 	Color string ("red", "green", etc)
> 	TheTesting reference to Testing
> 
> Testing
> 	Same as it was, except without cell_01, etc and without color_01, etc
> 
> Now, here's your findObjects query:
> $factory->findObjects ('@Testing', {
> 	CellTypeList.CellType => "microglia",
> 	CellColorList.Color   => "red"
> 	});

I'm not sure this really covers what I'm trying to do.  

I have up to three celltype identifications for any given image. 
I want to search "microglia" as a possibility in one and "muller" as a
possibility in another, and then "ganglion" in another (for example)

So, I am looking for way to do:
	$factory->findObjects ('@Testing', {
	       CellTypeList.CellType => "microglia",
	       CellTypeList.CellType => "muller",
	       CellTypeList.CellType => "ganglion",
       });

with OR's in between.  Doing 3 seperate queries would be a REAL
hassle,...especially if I want to count objects and do pagination of the
results.


I think it would be possible somehow to have a couple variations of OR
syntax.   A suggestion might be as follows:


	$factory->findObjects ('@Testing', {
	       [cell01, cell02, cell03 ] => "microglia",
       });

where the array is OR'ed with parenthasees  (cell01 OR cell02 OR cell03 )

for outside parenthasese, maybe something like this:

	$factory->findObjects ('@Testing', {
	       cell01  => "microglia",
	       ^cell02  => "microglia",
	       ^cell03 => "microglia",
       });
where the carrot symbol "^" (or some other character) tells the SQL
statement builder to put OR's instead of the default AND

possible?  

I really feel like not having any kind of an OR possibilities is a bit
of a handicap. 


I'm solving my problem at the moment doing a very hefty SQL select with
the DBH.   Not only do I have to do OR's, but I need to JOIN them over 3
or 4 tables.  Not pretty, but necessary.


	-august.


More information about the ome-devel mailing list