Scalr\Model\Entity\Role::getServersCount PHP Méthode

getServersCount() public méthode

Get the number of Servers which are using this Role
public getServersCount ( string $accountId = null, string $envId = null ) : integer
$accountId string optional Identifier of account
$envId string optional Identifier of environment
Résultat integer
    public function getServersCount($accountId = null, $envId = null)
    {
        $sql = "SELECT COUNT(*)\n                FROM servers s\n                JOIN farm_roles ON s.farm_roleid = farm_roles.id\n                WHERE farm_roles.role_id = ?";
        $args = [$this->id];
        if ($envId) {
            $sql .= " AND s.env_id = ?";
            $args[] = $envId;
        }
        if ($accountId) {
            $sql .= " AND s.client_id = ?";
            $args[] = $accountId;
        }
        return $this->db()->GetOne($sql, $args);
    }