//сам класс
class DataBase{
const BD_HOST = "localhost";
const BD_USER = "stas";
const DB_PASS = "stas";
const DB = 'CMS-Lite';
public function __construct(){
@mysql_connect(DB_HOST,DB_USER,DB_PASS);
@mysql_select_db(DB);
}
public function getDb(){
}
public function query($query){
return $query;
}
}
//использование класса
$mysqli = new DataBase;
$query = $mysqli->query('SELECT * FROM news');
while ( $row = mysql_fetch_array($query) ) {
foreach ($row as $col_value) {
print "$col_value";
}
}
Если написать без класса, а просто инструкции, то все проходит нормально:
@mysql_connect('localhost','stas','stas');
@mysql_select_db('CMS-Lite');
$query = mysql_query('SELECT * FROM news');
while ( $row = mysql_fetch_array($query) ) {
foreach ($row as $col_value) {
print "$col_value";
}
}
mysql_query('SELECT * FROM news') or die(mysql_error());