Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class conexao_banco {
- //Declarando os atributos
- private static $hostname;
- private static $usuario;
- private static $senha;
- private $banco;
- private $query;
- private $conexao;
- // function __construct() {
- // //Iniciando a conexão com o banco
- // $this->open();
- // }
- public function getQuery() {
- return $this->query;
- }
- public function getConexao() {
- return $this->conexao;
- }
- public function setQuery($query) {
- $this->query = $query;
- }
- public function open() {
- $this->conexao = mysql_connect("localhost", "root", "123456");
- if (!$this->conexao) {
- echo "Erro na conexão com o banco de dados!";
- } elseif (!$this->banco) {
- echo "Banco de dados inexistente";
- } else {
- $this->banco = mysql_select_db("teste");
- }
- }
- public function close() {
- mysql_close($this->conexao);
- }
- public function query($sql) {
- $this->query = mysql_query($sql);
- return $this->query;
- }
- // retorna quantas linhas aquela query resultou
- public function total_Linhas($sql) {
- return mysql_num_rows($this->query);
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement