Created
December 30, 2015 15:42
-
-
Save half2me/f047e8e49c54b890ece2 to your computer and use it in GitHub Desktop.
Extract where
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$allowedIds = $this->Websites->Products->find() | |
->extract(['id']) | |
->where(['reservation_id IS' => null]) // Product is not already reserved | |
->where(['size' => $converter->convert($request['size_eu'], $gender['gender'])]) // Product size matches | |
->where(['id IN' => TableRegistry::get('ProductsWebsites')->find() // Product belongs to the Website | |
->select(['product_id']) | |
->where(['website_id' => $website->id]) | |
]) | |
->where(['product_info_id IN' => $this->Websites->Products->ProductInfo->find() // Product sku matches | |
->select('id') | |
->where(['sku' => $request['sku']]) | |
]) | |
->toList(); | |
debug($allowedIds); |
ionas
commented
Dec 30, 2015
Thanks @lonas Is there some way I can use this have an update() statement with a ->where(['id IN' => $allowedIds]);
?
It would be nice to not have to do 2 queries, but have it as a sub-query.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment