Follow along with the video below to see how to install our site as a web app on your home screen.
Примечание: This feature may not be available in some browsers.
function mysql($sql){
$count++;
result mysql_query($sql);
}
class MySQL_class {
public $dblink = null;
public $result = array ();
public $count_query = 0;
public $error_MySQL = null;
public $query_sql = array();
public function __construct() {
$this->dblink = @mysql_pconnect ( db_host, db_username, db_password );
if ($this->dblink && mysql_select_db ( db_database )) {
if (version_compare ( mysql_get_server_info (), '4.1', ">=" ))
mysql_query ( '/*!40101 SET NAMES "utf-8" */' );
mysql_query ( 'set character_set_connection=utf8' );
mysql_query ( 'set character_set_client=utf8' );
mysql_query ( 'set character_set_results=utf8' );
} else {
die ( 'Ошибка при подключении к базе данных, эта ошибка может быть вызвана не правильными данными для подключения к базе данных, или на данный момент база данных не работает. Приносим свои извинения.');
}
}
public function query($sql_query, $id_query = 'main') {
if(is_array($sql_query)) {
foreach ($sql_query as $sql_query_id) {
$result = mysql_query ( $sql_query_id, $this->dblink );
}
return true;
}
$result = mysql_query ( $sql_query, $this->dblink );
if (!$result) {
if (debug) {
$this -> error_MySQL .= '<pre><br>' . mysql_error () . '<br>' . $sql_query . '<br></pre>';
}
return false;
} else {
$this -> query_sql [] = $sql_query;
$this->result [$id_query] = $result;
$this -> count_query = $this -> count_query + 1;
return true;
}
}
function fetch_object($id_query = 'main') {
if ($this->result [$id_query]) {
$this->dbrow = mysql_fetch_object ($this->result[$id_query]);
return $this->dbrow;
}
}
}
$MySQL_class = new MySQL_class();
$MySQL_class ->query ( "select * base" );
while ( $base_result = $MySQL_class ->fetch_object () ) {
// Чего то делаем тут
}
echo 'Количество SQL запросов ' . $MySQL_class -> count_query . '<br>';
if(!empty($MySQL_class -> error_MySQL)) {
echo 'Ошибки при выполнении SQL ' . $MySQL_class -> error_MySQL . '<br>';
}
foreach ($MySQL_class -> query_sql as $query_sql) {
echo $query_sql . '<br>';
}