is it safely way to use Mysqli_connect link in a function as GLOBALS like on following example ? What problems might I face on with this way ?
function dbconnect(){
$link = mysqli_connect($db['host'], $db['user'], $db['pass']);
mysqli_select_db($link, $db['db']);
return $link;
}
function something_query($sql){
return mysqli_query($GLOBALS['conn'], $sql);
}
$conn = dbconnect();
$newsql = 'select * from table where 1';
something_query($newsql);
edit 1 : $conn is an unique string on whole code and it does not use as param in query