Here is the simplified code of my class:
Code: Select all
<?php
class App {
var $db = null;
function App() {
$this->db = $this->conectDB();
}
function conectDB() {
$dbname = 'myDB';
$dbserver = 'localhost';
$dbuser = 'root';
$dbpass = 'password';
$db = mysql_connect($dbserver, $dbuser, $dbpass) or trigger_error(mysql_error(),E_USER_ERROR);
mysql_select_db($dbname, $db);
return $db;
}
function executeQry() {
$query = "SELECT * FROM sampletable";
$result = mysql_query($query,$this->db);
if (!$result) {
echo "query did not get executed";
}
}
}
?>How structure a class with database conectivity? Unfortunatly PEAR:DB is not an option.
Any help is greatly appreciated,
HEMOglobina