1
I’m working with the CakePHP 3.0
and created a query
for his ORM
, this query is working perfectly but now I need that if a certain parameter is 0 or nothingness is passed to the class method where
is deleted.
Method that creates the query
to the ORM
public function listProductsByTrend($subCategoryId, $productsQuantity, $column, $order)
{
$products = TableRegistry::get('products');
$query = $products->find();
$query->select(['product_name', 'quantity', 'sold', 'description', 'price', 'old_price', 'thumbnail'])
->where(['sub_category_id' => $subCategoryId])
->order([$column => $order])
->limit($productsQuantity);
return $query;
}
If $subCategoryId for 0 or not even something passed the clasula where
should be deleted.