Check if domain name already exists

Discussion in 'Developers' Forum' started by Massimiliano Micol, Jul 20, 2021.

  1. Massimiliano Micol

    Massimiliano Micol New Member

    Good morning,
    I'm trying to determine if a domain name is already present in the database. I was trying to use the function
    PHP:
    $client->domains_get_all_by_user($session_id$sys_groupid);
    but I realized I have no clue how to retrieve the sys_groupip value. I looked up in the database, and I got these results:
    [​IMG]
    From what I see, the sys_groupid of the client is different from the sys_groupid of the domain, which I don't understand how works. Each time I create a domain it seems to use the groupid value inside the sys_group table - instead of the one provided by
    PHP:
    $client->client_get($session_id, array('username' => 'cl21g001'))[0]['sys_groupid'];
    My question is: how can I determine in an easy way if a domain is already present in the database or not?
    Thank you
     
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    Code:
    $domain = $client->sites_web_domain_get($session_id, array('domain' => 'mydomain.tld'));
    if you get an array back with the domain details, then the domain exists, otherwise, you get false.
     
  3. till

    till Super Moderator Staff Member ISPConfig Developer

    The sys_groupid is the ID of the group that owns a record and each client has it's own group, see sys_group table. This works similar to the Linux user and group system. The client is not owned by itself, the owner of the client is either the admin or the reseller if it belongs to a reseller.
     
  4. till

    till Super Moderator Staff Member ISPConfig Developer

    Btw, the function I posted above is about websites, if you want to query the domain list of the client module, use:

    Code:
    $domain = $client->domains_domain_get($session_id, array('domain' => 'mydomain.tld'));
     
    Massimiliano Micol likes this.
  5. Massimiliano Micol

    Massimiliano Micol New Member

    I was actually asking about the domain function, but you read my mind! This works, thank you till!
     

Share This Page