Przekształcanie kodu w PHP 7.0 i powyżej
Aby klasy pozostały robotnikami.Kilka wierszy z kodu:
Klasy DBI
{ {
Opis właściwości klasy
$dbh, #database link handler
$sth, # resource handler
$errno, numer błędu w bazie danych
$errmsg, #database error message
$host i #host
$user, # nazwa użytkownika
$pass i #password
$database, nazwa bazy danych
$q, # kwery tekst
$log_file = '', # Log FileName, if empty - no loging mysqlog.txt
$time_limit = 1.5; # Log only querys above this time
### Podłącz się do serwera i wybierz bazę danych
funkcja connect($host="",$user="",$pass="", $database="")
{ {
error_reporting(!E_WARNING) w oparciu o
$this->dbh=mysql_connect($host,$user,$pass);# or $this->GetError("Connection failed");
jeśli (!$this->dbh){
Echo "Na serwerze prowadzone są prace techniczne.Przepraszam za podane dyskomforty.„;wyjście ;
Powrót fałszywy;
Wszyscy →
error_reporting (E_ALL i ~E_NOTICE)
mysql_select_db($database) or $this->GetError("Database selection failed");
$this->database = bazy danych
powrót do prawdy;
## set auto_recoding from cp1251 to koi8ukr
funkcja cp1251_koi8(){
$this->query("set option character set cp1251_koi8");
I tak dalej.
Opinia zleceniodawcy o współpracy z Anatoly Demchenko
Przekształcanie kodu w PHP 7.0 i powyżejDziękuję . Bardzo szybko . Będę się jeszcze rozmawiał.
Opinia freelancera o współpracy z Aleksey Mitroshin
Przekształcanie kodu w PHP 7.0 i powyżejZ Aleksem miło się zajmować - wszystko, czego potrzeba, dał. Szybko sprawdziłem i zapłaciłem. Polecam !
-
<?
class DBI
{
## Class properties description
var $dbh, # database link handler
$sth, # resource handler
$errno, # database error number
$errmsg, # database error message
$host, # host
$user, # user name
$pass, # password
$database, # database name
$q, # query text
$log_file = '', # Log FileName, if empty - no loging mysqlog.txt
$time_limit = 1.5; # Log only querys above this time
#@@@ PUBLIC METHODS @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
### Connect to server and select database
function connect($host="",$user="",$pass="", $database="")
{
error_reporting(!E_WARNING);
$this->dbh=mysql_connect($host,$user,$pass);# or $this->GetError("Connection failed");
if (!$this->dbh){
echo "На сервере ведутся технические работы. Извините за доставленное неудобство.";
exit;
return false;
}else{
error_reporting(E_ALL & ~E_NOTICE);
mysql_select_db($database) or $this->GetError("Database selection failed");
$this->database = $database;
return true;
}
}
## set auto_recoding from cp1251 to koi8ukr
function cp1251_koi8(){
$this->query("set option character set cp1251_koi8");
}
## set auto_recoding to default
function to_default(){
$this->query("set option character set DEFAULT");
}
### Send query
function query($query="", $debug_query = 0){
global $debug_query;
if(!$query){
echo "DB class error: [No query parameter]";
$this->close();
exit;
}
if($debug_query){
//echo "<pre>".$query."</pre>";
echo $query."<br>---<br>";
}
$this->q = $query;
$page_parse_time_start = microtime();
if($query)
$this->sth = mysql_query($query, $this->dbh) or $this->GetError("Query error");
if ($_SERVER['REQUEST_URI'] and $this->log_file)
$tmp = explode('.',$_SERVER['REQUEST_URI']);
if($this->log_file && !in_array(strtolower($tmp[count($tmp)-1]),array('jpg', 'png', 'gif'))){
$time_start = explode(' ', $page_parse_time_start);
$time_end = explode(' ', microtime());
$time_int = $time_end[1] + $time_end[0] - ($time_start[1] + $time_start[0]);
if($time_int > $this->time_limit){
$parse_time = number_format($time_int, 3);
###### лог запросов в файл #########
$query = ereg_replace("\r", "", $query);
$query = ereg_replace("\n", " ", $query);
global $ROOT_DIRECTORY, $HTTP_AFTER, $domain;
$fp = fopen($ROOT_DIRECTORY.$this->log_file, "a+");
fwrite($fp, date(" H:i:s")." ".$parse_time." ".$_SERVER['REMOTE_ADDR']." ".($domain ? $domain.'.'.$HTTP_AFTER : $_SERVER['SERVER_NAME']).$_SERVER['REQUEST_URI']." ".session_id()." ".$query."\n");
fclose($fp);
####################################
}
}
return $this->sth;
}
### Return number of result rows of last SELECT QUERY
function num_rows($linkno=0)
//$linkno - number of link resource (default = 0)
{
if (!$this->sth && !$linkno){ ## IF NO RESOURCE
echo "No performed SELECT query: [Invalid resource link]";
exit;
}
$num=mysql_num_rows($linkno ? $linkno : $this->sth);
return $num;
}
### Return number of affected rows of performed query
function affected_rows()
//$linkno - number of link resource (default = 0)
{
$num=mysql_affected_rows();
return $num;
}
### Fetch row as array
function fetch_row($linkno=0)
//$linkno - number of link resource (default = 0)
{
//echo $linkno;
return mysql_fetch_row($linkno ? $linkno : $this->sth);
}
### Fetch row as ac array
function fetch_array($linkno=0)
//$linkno - number of link resource (default = 0)
{
return mysql_fetch_array($linkno ? $linkno : $this->sth);
}
### Fetch row as hash
function fetch_hash($linkno=0)
//$linkno - number of link resource (default = 0)
{
return mysql_fetch_assoc($linkno ? $linkno : $this->sth);
}
### Data seek; Move result pointer to the row $row, by default 0
function seek($row=0, $linkno=0)
//$linkno - number of link resource (default = 0)
{
return mysql_data_seek($linkno ? $linkno : $this->sth,$row);
}
### Fetch field
function fetch_field($row=0,$field=0, $linkno=0){
//$linkno - number of link resource (default = 0)
$flag=true;
if ($row<0 || $row>=$this->num_rows()){
//echo "Data seek error: [Invalid row offset ($row)]";
return false;
}
if ( (!is_int($field)) || $field<0 || $field>=$this->num_fields()){
echo "Field seek error: [Invalid field offset ($field)]";
exit;
}
return mysql_result($linkno ? $linkno : $this->sth,$row,$field);
}
function last_id(){
return mysql_insert_id($this->dbh);
}
function num_fields($linkno=0){
//$linkno - number of link resource (default = 0)
if (!$this->sth && !$linkno){
echo "Fetch length error: [Invalid resource link]";
exit;
}
return mysql_num_fields($linkno ? $linkno : $this->sth);
}
### Close connection
function close(){
@mysql_close($this->dbh);
}
#@@@ PRIVATE METHODS @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
## Get database error parameters. Print error, close database connection and terminate
function GetError($hint="")
{
$this->errno=mysql_errno($this->dbh);
$this->errmsg=mysql_error($this->dbh);
$this->close();
$this->q = eregi_replace("select ", "<b>SELECT</b> ", $this->q);
$this->q = eregi_replace("update ", "<b>UPDATE</b> ", $this->q);
$this->q = eregi_replace("insert ", "<b>INSERT</b> ", $this->q);
$this->q = eregi_replace(" from ", "\n<b>FROM</b> ", $this->q);
$this->q = eregi_replace(" left ", "\n<b>LEFT</b> ", $this->q);
$this->q = eregi_replace(" right ", "\n<b>RIGHT</b> ", $this->q);
$this->q = eregi_replace(" join ", " <b>JOIN</b> ", $this->q);
$this->q = eregi_replace(" where ", "\n<b>WHERE</b> ", $this->q);
$this->q = eregi_replace(" order ", "\n<b>ORDER</b> ", $this->q);
$this->q = eregi_replace(" group ", "\n<b>GROUP</b> ", $this->q);
$this->q = eregi_replace(" limit ", "\n<b>LIMIT</b> ", $this->q);
$e = debug_backtrace();
echo '<b>Error</b> in line: <b>'.$e[1]['line'].'</b> [<font color="green">'.$e[1]['file'].'</font>]';
echo '<pre>';
echo $this->q;
echo '</pre>';
echo "<b>$hint.</b> Error #",$this->errno,"<blockquote>",$this->errmsg,"</blockquote>";
exit;
}
}
?>
-
Здравствуйте. Пришлите сам класс.
-
Aktualne zlecenia dla freelancerów w kategorii PHP
Wielostronicowy szablon HTML strony internetowej do zakładów online i parsowanie API meczów (
91 PLN
Mam Sportsbook API, potrzebuję pobrać z internetu szablon strony internetowej do zakładów online i zintegrować tam parsowanie meczów oraz system płatności) zadanie jest bardzo proste, napiszcie, kto od razu może to zrobić) w zasadzie potrzebna jest dziurawa strona do testów z lk… PHP, Python ∙ 6 godzin 40 minut temu ∙ 12 ofert |
Rozwiązać problem z obciążeniem hostingu strony na PrestaShopStrona z każdym miesiącem potrzebuje coraz więcej zasobów. Odpowiedź hostingu: Podczas sprawdzania serwera odnotowano zwiększone obciążenie ze strony serwera baz danych MySQL. W momentach wystąpienia błędu 500 proces MySQL wykorzystuje znaczną część zasobów procesora, co może… PHP, Bazy danych i SQL ∙ 7 godzin 35 minut temu ∙ 19 ofert |
Potrzebna integracja KeyCRM → PRRO KaszalotTrzeba skonfigurować integrację między KeyCRM a PRRO Kaszalot. Podczas składania zamówienia w KeyCRM dane mają być automatycznie przesyłane do Kaszalota: • informacje o zamówieniu • towary, asortyment • ceny • ilość Szczegóły w wiadomości prywatnej. Content Management Systems, PHP ∙ 8 godzin 56 minut temu ∙ 18 ofert |
Strona na WordPressie z wykorzystaniem motywu Kadence i Kadence Blocks.
820 PLN
Musimy stworzyć stronę na WordPressie z wykorzystaniem motywu Kadence oraz Kadence Blocks. Sklepu internetowego nie będzie (chociaż prawdopodobnie zostanie dodany w przyszłości). Potrzebna jest strona główna oraz kilka stron wewnętrznych. Grafika jest już gotowa, struktura… Content Management Systems, PHP ∙ 1 dzień 18 godzin temu ∙ 37 ofert |
Opracowanie 2 stron internetowych zorientowanych na SEO do sprzedaży części (quady i sprzęt specjalistyczny)Opracowanie dwóch specjalistycznych stron internetowych do sprzedaży części zamiennychOgólne informacjeNależy opracować dwie specjalistyczne strony:Części zamienne do quadów, UTV, SSV i innego podobnego sprzętu.Części zamienne do sprzętu specjalistycznego.Istniejąca strona… PHP, Programowanie stron internetowych ∙ 2 dni 15 godzin temu ∙ 76 ofert |