Scalr\Model\Entity\Role::getFarmsCount PHP Метод

getFarmsCount() публичный Метод

Gets the number of Farms which are using this Role
public getFarmsCount ( integer $accountId = null, integer $envId = null ) : integer
$accountId integer optional Identifier of account
$envId integer optional Identifier of environment
Результат integer Returns farm's count which uses current role
    public function getFarmsCount($accountId = null, $envId = null)
    {
        $sql = "SELECT COUNT(DISTINCT f.id)\n                FROM farm_roles fr\n                JOIN farms f ON fr.farmid = f.id\n                WHERE fr.role_id = ?";
        $args = [$this->id];
        if ($accountId) {
            $sql .= " AND f.clientid = ?";
            $args[] = $accountId;
        }
        if ($envId) {
            $sql .= " AND f.env_id = ?";
            $args[] = $envId;
        }
        return $this->db()->GetOne($sql, $args);
    }