La classe che sto abbozzando è questa
Codice: Seleziona tutto
<?php
// Gestione connessione al db
class Connessionedb
{
// Metodi
public function __constructor($nomeHost = null, $nomeDataBase = null)
{
if($nomeHost == null)
$nomeHost = $this->_hostDbDB;
if($nomeDataBase == null)
$nomeDataBase = $this->_nomeDB;
$this->_db_connect = mysql_connect($nomeHost, $this->_utente, $this->_password);
$this->_db = mysql_select_db($nomeDataBase);
}
public function query($query)
{
if($query != null)
{
// Esegui query
}
else
die("Immettere query valida\n</br>");
}
public function getProvince()
{
$queryProvince = "select * from province";
print "Prova ".$this->_utente." asd ".$this->_password."\n<br>";
// $this->_db_connect = mysql_connect($this->_hostDb, $this->_utente, $this->_password);
// $this->_db = mysql_select_db("pone");
return mysql_query($queryProvince, $this->_db_connect) or die mysql_error();
}
// Attributi
private $_nomeDb = "pone";
private $_utente = "lavoro";
private $_password = "lavoro";
private $_hostDb ="localhost";
private $_db = null;
private $_db_connect = null;
}
?>
