function hosting_get_db_server in Hosting 7.4
Same name and namespace in other branches
- 5 db_server/hosting_db_server.module \hosting_get_db_server()
- 6.2 db_server/hosting_db_server.module \hosting_get_db_server()
- 7.3 db_server/hosting_db_server.module \hosting_get_db_server()
Find the database server.
File
- db_server/
hosting_db_server.module, line 30 - Allow Hostmaster to configure database servers.
Code
function hosting_get_db_server($hostname) {
if (_hosting_valid_ip($hostname)) {
$ip = $hostname;
$hostname = gethostbyaddr($hostname);
}
else {
$ip = gethostbyname($hostname);
}
$result = db_query("SELECT nid FROM {node} WHERE title in ('%s', '%s') and type = :type", array(
':type' => 'server',
'' => $ip,
'' => $hostname,
))
->fetchField();
if ($result) {
return node_load($result);
}
return FALSE;
}