Exemple #1
0
function getLink()
{
    // the one place where we make access to the database and talk with mysql
    $pars = findAccessParameters();
    $host = $pars[0];
    $user = $pars[1];
    $passwd = $pars[2];
    //echo " HOST: $host  USER $user  PASS: $passwd";
    //echo " HOST: $host  USER $user";
    $link = mysqli_connect($host, $user, $passwd, 'Teaching') or die('Error ' . mysqli_error($link));
    return $link;
}
Exemple #2
0
 public static function getReader()
 {
     $pars = findAccessParameters();
     $host = $pars[0];
     $user = $pars[1];
     $passwd = $pars[2];
     //echo " HOST: $host  USER: $user  PASS: $passwd";
     static $db = null;
     if ($db === null) {
         $db = new PDO('mysql:host=' . $host . ';dbname=Teaching;charset=utf8', $user, $passwd);
     }
     return $db;
 }