Git Product home page Git Product logo

Comments (3)

dimitrihilverda avatar dimitrihilverda commented on August 26, 2024 1

Yes I did, sort of,
I do a query, then get results, with the results I do another query, and so on until all are done.
https://gist.github.com/dimitrihilverda/dde5fa04b05bdb1a94634dba9b25e64a

from jsonq.

tomkeysers avatar tomkeysers commented on August 26, 2024

I'm doing and wondering the same thing.
@dimitrihilverda did you ever figure this out?

from jsonq.

tomkeysers avatar tomkeysers commented on August 26, 2024

I actually found another way to do this using the reset() function. Likeso:

$jsonq = new Jsonq();
$jsonq->json(json_encode($result));

$res = $jsonq
	->where('subcategory_website', 'contains', $this->sublevel)
	->get();

if( isset($_GET['colour']) ) {
	$colour_filters = $_GET['colour'];
	$colour_filters = explode(',', $colour_filters);

	$jsonq->reset();
	foreach ($colour_filters as $key => $value) {
		$jsonq->orWhere('colour_website', 'contains', $value);	
	}
	$res = $jsonq->get();
}

if( isset($_GET['material']) ) {
	$material_filters = $_GET['material'];
	$material_filters = explode(',', $material_filters);

	$jsonq->reset();
	foreach ($material_filters as $key => $value) {
		$jsonq->orWhere('material_website', 'contains', $value);
	}
	$res = $jsonq->get();
}

if( isset($_GET['age']) ) {
	$age_filters = $_GET['age'];
	$age_filters = explode(',', $age_filters);

	$jsonq->reset();
	foreach ($age_filters as $key => $value) {
		$jsonq->orWhere('Age (website)', '=', $value);
	}
	$res = $jsonq->get();
}

Notice that I start off with one required where query, and after that use $jqonq->reset() to function as a sort of AND to then be able to insert as many OR's as needed. And if needed followed again with a reset() AND, and again some OR's.

In the end my $res will hold the result of all queries.

from jsonq.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.