Created
November 4, 2014 11:44
-
-
Save otavioschwanck/17bb5821d3f8494bb74e to your computer and use it in GitHub Desktop.
Conexão com banco de dados MySql usando a linguagem PHP.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Conexão com banco de dados MySql usando mysql | |
@autor Otávio Schwanck | |
*/ | |
class banco{ | |
//Endereço do servidor | |
private static $endereco = "localhost"; | |
//Login do usuário do servidor | |
private static $login = "root"; | |
//Senha do usuário do servidor | |
private static $senha = ""; | |
//Schema a ser selecionado | |
private static $banco = ""; | |
//Variavel da conexão que será retornada. | |
private static $conexao; | |
//Charset a ser utilizado. | |
private static $charset = "utf8"; | |
public static function getConexao(){ | |
/** | |
Conecta com o banco de dados e retorna a conexão. Se falhar, irá retornar null. | |
@return Connection | |
@exemple $conexao = banco::getConexao(); | |
*/ | |
banco::$conexao = mysql_connect(banco::$endereco, banco::$login, banco::$senha); | |
mysql_select_db(banco::$banco, banco::$conexao); | |
mysql_set_charset(banco::$charset, banco::$conexao); | |
return banco::$conexao; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment