SHARE
TWEET

Exemplo conexão com PDO - CloudSql

MatheusMouraHT Sep 19th, 2019 110 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. echo "Conectando...";
  4. $host = "mysql:unix_socket=/cloudsql/ID_INSTANCIA;dbname=NOME_BANCO";
  5. $user = "USUARIO";
  6. $password ="SENHA";
  7.  
  8. try{
  9.   // create a PDO connection with the configuration data
  10.   $conn = new PDO($host, $user, $password);
  11.  
  12.   // display a message if connected to database successfully
  13.   if($conn){
  14.     echo "Connected database successfully!";
  15.   }
  16.  
  17.  } catch (PDOException $e) {
  18.   // report error message
  19.   echo $e->getMessage();
  20.  }
  21. ?>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top