EDIT: Found this which works quite well for what I need: https://github.com/jstayton/QueryBuilder
I'm building a small project where I need to query a table a couple of times.
It works like this:
1) Multi-select box of distinct items in Column 1
2) Ajax query the db for distinct records in Column 2 where Column 1 IN (vals
previously selected)
3) Does this 3-4 more times, gradually cutting down the available options by
adding IN statements to the MySQL
Now it's not impossible to this manually by setting up a couple pre-built queries and binding the various params to them, but I'd like to make it a bit nicer than that. Something along the lines of....
$qry->from("mytable");
$qry->column("col1");
$qry->column("col2");
$qry->addWhere("col1", "in", $arrayOfVals);
$qry->addWhere("col2", "in", $arrayOfVals2);
Or something to that effect, that will build it out in a cleaner way.
Alternatively, if someone has a suggestion on a different way to do this, I'm open to that too.
DB::select ('col1', 'col2')->from ('mytable')->where ('col1', 'IN', $arrayOfVals)->and_where ('col2', 'IN', $arrayOfVals2)->execute ();? Kohana's Query Builder, you could try to extract it, or just do the sensible thing and use Kohana ;)