Jump to content

Recommended Posts

Posted
9 hours ago, activa said:

What is the best and correct query to get all services that use the package X . Basing in the package_group_id return incorrect data for some packages .

take this, i use it and i can get the total services using the package X with option to filter per service status

    public function getUsedServices($package_id, $service_status = null)
    {
        $this->Record->select('services.id')->from('package_pricing')->
            innerJoin('services', 'services.pricing_id', '=', 'package_pricing.id', false)->
            where('package_pricing.package_id', '=', $package_id);

		if ($service_status) {
			$this->Record->where('services.status', '=', $service_status);
		}

		return $this->Record->numResults();	
    }

 

you can use it as getUsedServices($package_id, 'active')  to get total active services using the package X

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...