CN110888855A - Method and terminal for being compatible with multi-version database in PHP environment - Google Patents

Method and terminal for being compatible with multi-version database in PHP environment Download PDF

Info

Publication number
CN110888855A
CN110888855A CN201811041389.9A CN201811041389A CN110888855A CN 110888855 A CN110888855 A CN 110888855A CN 201811041389 A CN201811041389 A CN 201811041389A CN 110888855 A CN110888855 A CN 110888855A
Authority
CN
China
Prior art keywords
php
version
low
database
version database
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Withdrawn
Application number
CN201811041389.9A
Other languages
Chinese (zh)
Inventor
刘德建
陈翔
杨汉才
江凌帆
朱宗龙
陈秀琛
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Fujian TQ Digital Co Ltd
Original Assignee
Fujian TQ Digital Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Fujian TQ Digital Co Ltd filed Critical Fujian TQ Digital Co Ltd
Priority to CN201811041389.9A priority Critical patent/CN110888855A/en
Publication of CN110888855A publication Critical patent/CN110888855A/en
Withdrawn legal-status Critical Current

Links

Images

Abstract

The invention provides a method and a terminal for being compatible with a multi-version database in a PHP environment, wherein a new drive is added for a PHP, an engine used by the new drive points to a drive of a low-version database, and the low-version database is connected with the drive of the low-version database; therefore, the database with different versions can be switched and connected at any time in the PHP environment, the condition that the subsequent PHP version cannot be upgraded due to the fact that the connected database version is low is avoided, the performance and the stability of the PHP environment are improved, patching updating can be carried out according to the updating of the latest PHP version, and the safety of a site is improved; when the PHP version is upgraded, data migration of the data of the low version is not needed, and development and maintenance cost is reduced.

Description

Method and terminal for being compatible with multi-version database in PHP environment
Technical Field
The invention relates to the field of computer software, in particular to a method and a terminal for being compatible with a multi-version database in a PHP environment.
Background
At present, the default of the version above PHP5.3 is MYSQLND drive, and when a PHP data object is used to connect a MYSQL4.0 version database, access is prohibited due to the problem of compatibility between the version above PHP5.3 and the MYSQL4.0 version database. However, at present, a part of databases of websites still use the MYSQL4.0 version database, which causes that the version of PHP is limited and cannot be upgraded, so that version holes and potential safety hazards exist, the performance cannot be improved, further expansion cannot be performed, and the upgrade and safety of website frames are affected.
However, most companies still use the MYSQL4.0 version database for historical reasons, and if the MYSQL database is uniformly upgraded to the latest version, the data migration is difficult due to the large version difference, and the stability of the system is also affected, so that the implementation cost is expensive.
Therefore, how to switch and connect databases of different versions in the PHP environment becomes a problem to be solved urgently.
Disclosure of Invention
The technical problem to be solved by the invention is as follows: a method and a terminal for being compatible with multi-version databases in a PHP environment are provided, and databases of different versions can be switched and connected at any time in the PHP environment.
In order to solve the technical problems, the invention adopts the technical scheme that:
a method for being compatible with a multi-version database in a PHP environment comprises the following steps:
s1, adding a new drive for the PHP, and enabling an engine used by the new drive to point to a drive of a low-version database;
and S2, connecting the low version database through the drive of the low version database.
In order to solve the technical problem, the invention adopts another technical scheme as follows:
a terminal compatible with multi-version databases in a PHP environment, comprising a memory, a processor and a computer program stored on the memory and executable on the processor, the processor implementing the following steps when executing the computer program:
s1, adding a new drive for the PHP, and enabling an engine used by the new drive to point to a drive of a low-version database;
and S2, connecting the low version database through the drive of the low version database.
The invention has the beneficial effects that: adding a new drive for the PHP, enabling an engine used by the new drive to point to a drive of a low-version database, and connecting the engine with the low-version database through the drive of the low-version database; therefore, the database with different versions can be switched and connected at any time in the PHP environment, the condition that the subsequent PHP version cannot be upgraded due to the fact that the connected database version is low is avoided, the performance and the stability of the PHP environment are improved, patching updating can be carried out according to the updating of the latest PHP version, and the safety of a site is improved; when the PHP version is upgraded, data migration of the data of the low version is not needed, and development and maintenance cost is reduced.
Drawings
FIG. 1 is a flowchart of a method for compatibility with a multi-version database in a PHP environment according to an embodiment of the present invention;
fig. 2 is a schematic structural diagram of a terminal compatible with a multi-version database in a PHP environment according to an embodiment of the present invention;
FIG. 3 is a detailed flowchart of a method for compatibility with a multi-version database in a PHP environment according to an embodiment of the present invention;
FIG. 4 is a diagram illustrating the adaptation of a driver to a database in a method for compatibility with a multi-version database in a PHP environment according to an embodiment of the present invention;
description of reference numerals:
1. a terminal compatible with a multi-version database in a PHP environment; 2. a memory; 3. a processor.
Detailed Description
In order to explain technical contents, achieved objects, and effects of the present invention in detail, the following description is made with reference to the accompanying drawings in combination with the embodiments.
The most key idea of the invention is that the PHP environment can be switched and connected with databases of different versions at any time by adding a new drive to the PHP and directing an engine used by the new drive to the drive of the low-version database.
Referring to fig. 1, a method for being compatible with a multi-version database in a PHP environment includes the steps of:
s1, adding a new drive for the PHP, and enabling an engine used by the new drive to point to a drive of a low-version database;
and S2, connecting the low version database through the drive of the low version database.
From the above description, the beneficial effects of the present invention are: adding a new drive for the PHP, enabling an engine used by the new drive to point to a drive of a low-version database, and connecting the engine with the low-version database through the drive of the low-version database; therefore, the database with different versions can be switched and connected at any time in the PHP environment, the condition that the subsequent PHP version cannot be upgraded due to the fact that the connected database version is low is avoided, the performance and the stability of the PHP environment are improved, patching updating can be carried out according to the updating of the latest PHP version, and the safety of a site is improved; when the PHP version is upgraded, data migration of the data of the low version is not needed, and development and maintenance cost is reduced.
Further, the S1 specifically includes:
s11, compiling a PHP version without extension;
s12, modifying the drive registration name of the native drive of the non-extended PHP version into a name matched with the drive of the low-version database, and correspondingly modifying the name of the corresponding PHP extension module;
s13, enabling an engine used by a driver in the PHP expansion module to point to a lib package of the driver of the low-version database, and compiling the PHP expansion module to obtain a file after compiling is completed;
and S14, introducing the compiled file into the PHP environment.
According to the description, the condition that lib points to abnormity due to the fact that soft connection cache exists after PHP version compiling is avoided by compiling the PHP without expansion; by correspondingly modifying the drive registration name and the name of the PHP extension module, the conflict between the application expansion and the drive and expansion module in the preset PHP environment is avoided; connecting with the low-version database by pointing the engine to a driven lib package of the low-version database; the compiled file is introduced into the PHP environment, so that the databases of different versions can be switched and connected at any time in the PHP environment.
Further, the step S2 includes:
the lib package driven by the low version database is connected with the low version database.
As can be seen from the above description, the lib package driven by the low-version database is connected to the low-version database, and the engine used by the driver in the PHP expansion module points to the lib package driven by the low-version database, so that the connection between the driver in the PHP expansion module and the low-version data is realized.
Further, between the steps S12 and S13, the method further includes:
and newly adding a variable for setting the security authentication parameter of the database in the PHP extension module, and registering the variable so that the variable can be called externally.
As can be seen from the above description, the compatibility problem with the low-version security authentication is solved by newly adding and registering a variable for setting the security authentication parameter of the database in the PHP extension module.
Further, the step S13 further includes:
and correspondingly modifying the file name of the compiled file according to the name of the driver of the low-version database.
As can be seen from the above description, by modifying the file name of the compiled file to correspond to the name of the driver of the low-version database, a connection conflict with the low-version database due to file name mismatch is avoided.
Referring to fig. 2, a terminal compatible with multi-version database in PHP environment includes a memory, a processor and a computer program stored in the memory and running on the processor, wherein the processor executes the computer program to implement the following steps:
s1, adding a new drive for the PHP, and enabling an engine used by the new drive to point to a drive of a low-version database;
and S2, connecting the low version database through the drive of the low version database.
From the above description, the beneficial effects of the present invention are: adding a new drive for the PHP, enabling an engine used by the new drive to point to a drive of a low-version database, and connecting the engine with the low-version database through the drive of the low-version database; therefore, the database with different versions can be switched and connected at any time in the PHP environment, the condition that the subsequent PHP version cannot be upgraded due to the fact that the connected database version is low is avoided, the performance and the stability of the PHP environment are improved, patching updating can be carried out according to the updating of the latest PHP version, and the safety of a site is improved; when the PHP version is upgraded, data migration of the data of the low version is not needed, and development and maintenance cost is reduced.
Further, the S1 specifically includes:
s11, compiling a PHP version without extension;
s12, modifying the drive registration name of the native drive of the non-extended PHP version into a name matched with the drive of the low-version database, and correspondingly modifying the name of the corresponding PHP extension module;
s13, enabling an engine used by a driver in the PHP expansion module to point to a lib package of the driver of the low-version database, and compiling the PHP expansion module to obtain a file after compiling is completed;
and S14, introducing the compiled file into the PHP environment.
According to the description, the condition that lib points to abnormity due to the fact that soft connection cache exists after PHP version compiling is avoided by compiling the PHP without expansion; by correspondingly modifying the drive registration name and the name of the PHP extension module, the conflict between the application expansion and the drive and expansion module in the preset PHP environment is avoided; connecting with the low-version database by pointing the engine to a driven lib package of the low-version database; the compiled file is introduced into the PHP environment, so that the databases of different versions can be switched and connected at any time in the PHP environment.
Further, the step S2 includes:
the lib package driven by the low version database is connected with the low version database.
As can be seen from the above description, the lib package driven by the low-version database is connected to the low-version database, and the engine used by the driver in the PHP expansion module points to the lib package driven by the low-version database, so that the connection between the driver in the PHP expansion module and the low-version data is realized.
Further, between the steps S12 and S13, the method further includes:
and newly adding a variable for setting the security authentication parameter of the database in the PHP extension module, and registering the variable so that the variable can be called externally.
As can be seen from the above description, the compatibility problem with the low-version security authentication is solved by newly adding and registering a variable for setting the security authentication parameter of the database in the PHP extension module.
Further, the step S13 further includes:
and correspondingly modifying the file name of the compiled file according to the name of the driver of the low-version database.
As can be seen from the above description, by modifying the file name of the compiled file to correspond to the name of the driver of the low-version database, a connection conflict with the low-version database due to file name mismatch is avoided.
Referring to fig. 1, fig. 3 and fig. 4, a first embodiment of the present invention is:
the technical scheme of the invention is applied to a specific scene, a certain site uses a version more than PHP5.3 and is subsequently or need to be upgraded, and a MYSQL database of MYSQL4.0 and more versions is simultaneously connected and operated according to the business requirement;
the method for implementing the multi-version database compatibility in the PHP environment comprises the following steps:
s1, adding a new drive for the PHP, and enabling an engine used by the new drive to point to a drive of a low-version database;
specifically, the method comprises the following steps:
s11, compiling a PHP version without extension;
the method specifically comprises the following steps: firstly downloading PHP source codes, and performing non-expansion compiling and installation;
s12, modifying the driving registration name of the native driver of the non-expanded PHP version into libmysql, wherein the name is matched with the driving name of the MYSQL4.0 version database, the driving name of the MYSQL4.0 version database is libmysql, and modifying the name 'pdo _ MYSQL' of the PHP expansion module into 'pdo _ libmysql';
further comprising: modifying the constant prefix MYSQL into LIBMYSQL;
additionally arranging a variable PDO _ MYSQL _ SECURE _ AUTH used for setting a security authentication parameter of a MYSQL database in the PHP extension module for compatible low-version security authentication, and registering the variable so that the variable can be called externally;
the variable PDO _ MYSQL _ SECURE _ AUTH sets a SECURE _ AUTH parameter of MYSQL, in order to prevent a low-version MYSQL client (a MYSQL client smaller than a version 4.1) from accessing a high-version server in an old password authentication mode, the default enabling value of SECURE _ AUTH in a database of the version MySQL5-7 is 1;
wherein, when the enabled value is 0, the old _ password () encryption result is 16 bits, and the password () encryption result is 41 bits
When the enabled value is 1, the old _ password () and password () encryption results are 16 bits in the same way;
when a MYSQL client of a low version accesses a server of a high version, setting a SECURE _ AUTH parameter value in the variable PDO _ MYSQL _ SECURE _ AUTH to be 1;
referring to fig. 4, MYSQL officials provide a lib package connected with MYSQL, and pdo _ libmysql is communicated and interacted with a database of MYSQL version 4.0 through the lib package of libmysql; the native pdo _ MYSQL is communicated and interacted with the database of the version more than MYSQL4.0 through a lib packet of MYSQL nd;
s13, enabling an engine used by a driver in the PHP extension module to point to a lib package driven by a MYSQL4.0 version in a MYSQL official website, and compiling the PHP extension module to obtain a file after compiling is completed;
modifying the name of the compiled file pdo _ mysql.so as to be pdo _ libmysql.so according to the name of the MYSQL4.0 version driver;
and S14, introducing the compiled file into the PHP environment.
The method specifically comprises the following steps: and copying the pdo _ libmysql.so file into the PHP environment, and introducing the phP file according to a PHP application expansion mode, namely after introduction, the PHP environment comprises dual drives, wherein one drive is used for connecting a high version database, and the other drive is used for connecting a low version database.
And S2, connecting the low version database through the drive of the low version database.
The method specifically comprises the following steps:
and the lib package driven by the database of the MYSQL4.0 version is connected with the database of the MYSQL4.0 version.
In addition, on DSN writing connecting different versions of MYSQL databases, there is a distinction:
when the official driver of MYSQL version 4.0 is connected, the DSN writing is libmysql, wherein host is 127.0.0.1, namely the connection points to the libmysql provided by the MYSQL official;
when the native driver MYSQL nd of the version above MYSQL4.0 is connected, the DSN writing is MYSQL, host is 127.0.0.1, namely, the native driver MYSQL nd is pointed;
therefore, the database with the lower version and the higher version can be switched and connected at any time under the condition that the PHP is continuously upgraded above the 5.3 version or subsequently.
Referring to fig. 2, the second embodiment of the present invention is:
a terminal compatible with multi-version database in PHP environment, comprising a memory 2, a processor 3 and a computer program stored on the memory 2 and executable on the processor 3, wherein the processor 3 implements the steps of the first embodiment when executing the computer program.
In summary, according to the method and the terminal for being compatible with the multi-version database in the PHP environment provided by the present invention, a new driver is added to the PHP, and the engine used by the new driver is directed to the driver of the low-version database, and is connected to the low-version database through the driver of the low-version database; therefore, the database with different versions can be switched and connected at any time in the PHP environment, the condition that the subsequent PHP version cannot be upgraded due to the fact that the connected database version is low is avoided, the performance and the stability of the PHP environment are improved, data migration of low-version data is not needed when the PHP version is upgraded, the development and maintenance cost is reduced, patching updating can be carried out according to the latest PHP version updating, and the safety of a site is improved; the condition that lib points to an exception due to the fact that soft connection cache exists after PHP version compiling is avoided by compiling the PHP without extension; correspondingly modifying the drive registration name, the name of the PHP extension module and the file name of the compiled file, and avoiding conflict between the application extension and a drive and extension module in a preset PHP environment; the compatibility problem of the low-version security authentication is solved by newly adding and registering variables for setting the security authentication parameters of the database in the PHP extension module.
The above description is only an embodiment of the present invention, and not intended to limit the scope of the present invention, and all equivalent changes made by using the contents of the present specification and the drawings, or applied directly or indirectly to the related technical fields, are included in the scope of the present invention.

Claims (10)

1. A method for being compatible with a multi-version database in a PHP environment is characterized by comprising the following steps:
s1, adding a new drive for the PHP, and enabling an engine used by the new drive to point to a drive of a low-version database;
and S2, connecting the low version database through the drive of the low version database.
2. The method for being compatible with multi-version database in PHP environment as claimed in claim 1, wherein said S1 specifically comprises:
s11, compiling a PHP version without extension;
s12, modifying the drive registration name of the native drive of the non-extended PHP version into a name matched with the drive of the low-version database, and correspondingly modifying the name of the corresponding PHP extension module;
s13, enabling an engine used by a driver in the PHP expansion module to point to a lib package of the driver of the low-version database, and compiling the PHP expansion module to obtain a file after compiling is completed;
and S14, introducing the compiled file into the PHP environment.
3. The method for being compatible with multi-version database in PHP environment according to claim 2, wherein said step S2 comprises:
the lib package driven by the low version database is connected with the low version database.
4. The method for being compatible with multi-version database in PHP environment according to claim 2, further comprising between the steps S12 and S13:
and newly adding a variable for setting the security authentication parameter of the database in the PHP extension module, and registering the variable so that the variable can be called externally.
5. The method for being compatible with multi-version database in PHP environment as claimed in claim 2, wherein said step S13 further comprises:
and correspondingly modifying the file name of the compiled file according to the name of the driver of the low-version database.
6. A terminal compatible with multi-version database in PHP environment, comprising a memory, a processor and a computer program stored on the memory and executable on the processor, wherein the processor executes the computer program to perform the steps of:
s1, adding a new drive for the PHP, and enabling an engine used by the new drive to point to a drive of a low-version database;
and S2, connecting the low version database through the drive of the low version database.
7. The terminal compatible with multi-version database in PHP environment as claimed in claim 6, wherein said S1 specifically comprises:
s11, compiling a PHP version without extension;
s12, modifying the drive registration name of the native drive of the non-extended PHP version into a name matched with the drive of the low-version database, and correspondingly modifying the name of the corresponding PHP extension module;
s13, enabling an engine used by a driver in the PHP expansion module to point to a lib package of the driver of the low-version database, and compiling the PHP expansion module to obtain a file after compiling is completed;
and S14, introducing the compiled file into the PHP environment.
8. The multi-version database compatible terminal in PHP environment as claimed in claim 7, wherein said step S2 comprises:
the lib package driven by the low version database is connected with the low version database.
9. The PHP multi-version database compatible terminal in environment of claim 7, further comprising between the steps S12 and S13:
and newly adding a variable for setting the security authentication parameter of the database in the PHP extension module, and registering the variable so that the variable can be called externally.
10. The terminal compatible with multi-version database in PHP environment as claimed in claim 7, wherein said step S13 further comprises:
and correspondingly modifying the file name of the compiled file according to the name of the driver of the low-version database.
CN201811041389.9A 2018-09-07 2018-09-07 Method and terminal for being compatible with multi-version database in PHP environment Withdrawn CN110888855A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811041389.9A CN110888855A (en) 2018-09-07 2018-09-07 Method and terminal for being compatible with multi-version database in PHP environment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811041389.9A CN110888855A (en) 2018-09-07 2018-09-07 Method and terminal for being compatible with multi-version database in PHP environment

Publications (1)

Publication Number Publication Date
CN110888855A true CN110888855A (en) 2020-03-17

Family

ID=69744430

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811041389.9A Withdrawn CN110888855A (en) 2018-09-07 2018-09-07 Method and terminal for being compatible with multi-version database in PHP environment

Country Status (1)

Country Link
CN (1) CN110888855A (en)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO1998044438A1 (en) * 1997-03-31 1998-10-08 Sun Microsystems, Inc. Java-to-database connectivity server
CN1976320A (en) * 2006-12-22 2007-06-06 中国建设银行股份有限公司 Data access control method and system
CN106649837A (en) * 2016-12-29 2017-05-10 成都三零盛安信息系统有限公司 Database compatible method
CN107491390A (en) * 2017-08-15 2017-12-19 深圳市慧择时代科技有限公司 The method and device of replacement test environment configuration information
CN107902507A (en) * 2017-11-11 2018-04-13 林光琴 Control software field debugging system and adjustment method

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO1998044438A1 (en) * 1997-03-31 1998-10-08 Sun Microsystems, Inc. Java-to-database connectivity server
CN1976320A (en) * 2006-12-22 2007-06-06 中国建设银行股份有限公司 Data access control method and system
CN106649837A (en) * 2016-12-29 2017-05-10 成都三零盛安信息系统有限公司 Database compatible method
CN107491390A (en) * 2017-08-15 2017-12-19 深圳市慧择时代科技有限公司 The method and device of replacement test environment configuration information
CN107902507A (en) * 2017-11-11 2018-04-13 林光琴 Control software field debugging system and adjustment method

Similar Documents

Publication Publication Date Title
EP3128421B1 (en) Method, device, and system for achieving java application installation by cloud compilation
US9350610B2 (en) System and method for configuration management service
CN102187636B (en) Methods, apparatuses, and computer program products for determining a network interface to access a network resource
KR100965706B1 (en) Computer apparatus capable of code rewriting and method for code rewriting
US8230415B1 (en) On-demand advertising of software packages
US20060200814A1 (en) Software distribution with activation control
US11489722B2 (en) Network node policy generation and implementation
EP2722754B1 (en) Software appliance installation systems and methods
US20110145803A1 (en) Extension mechanism
CN111459511B (en) Application program downloading method and device and electronic equipment
WO2016062146A1 (en) Serial number information update method, device and terminal
KR20070008619A (en) Execution of unverified programs in a wireless device operating environment
US7685591B2 (en) Customizing a software application through a patch file
CN113760339A (en) Vulnerability repair method and device
CN110413292B (en) Light application installation method of application program, mobile terminal and storage medium
CN106547602B (en) Method for manufacturing operating system mirror image suitable for iSCSI protocol remote wireless loading
US9940461B2 (en) Enabling an external operating system to access encrypted data units of a data storage system
CN110888855A (en) Method and terminal for being compatible with multi-version database in PHP environment
CN102148831B (en) Method and system for safely controlling terminal application
CN113867756A (en) Software upgrading method, terminal equipment and readable storage medium
CN104516752A (en) Information processing method and electronic equipment
CN108762827B (en) Encryption service providing program calling method and terminal equipment
CN113010197A (en) Application silence upgrading method, system, terminal equipment and storage medium
CN113254029B (en) Peripheral interface setting method and device of terminal equipment and electronic equipment
CN114594990B (en) eMMC operation method, eMMC operation device, readable storage medium and electronic equipment

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
WW01 Invention patent application withdrawn after publication

Application publication date: 20200317

WW01 Invention patent application withdrawn after publication