


Practical PHP calls the java class and the java class reads the database to complete related operations_PHP tutorial
1 Establish the system ODBC data source photo (this time I am using Oracle 9i, please contact me if you don’t understand the detailed configuration)
2 Compile the DataBaseConnection.java file and put the compiled file into the class file directory supported by PHP
package com.inberkong.util;
/***************************************************** ***
* Programe File: Copy buffer pool DataBaseConnection.java
*Creat Date:3/28/2005(MM-DD-YYYY)
*Creat By :InberKong(GongYingBin)
* LastModifyDate :3/28/2005(MM-DD-YYYY)
* ModifyBy :InberKong(GongYingBin)
* Function :Get the Oracle DataBaseConnectionPool
//A tool class for finding data sources.
*************************************************** *****/
import java.sql.*;
//Tool class for connecting to the database.
public class DataBaseConnection
{
/**
*A static method that returns a database connection.
*/
public static Connection getConnection()
{
Connection con=null;
Try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc:odbc:photo","photo","inberkong");//Data source connection information
}
catch(Exception e)
{
e.printStackTrace();
}
Return con;
}
}
3 Compile the processing class for reading the data table and put the processing class into the Java class directory called by PHP
This is a processing class that reads the user role table and returns a JS array of the relationship between users and roles GetUserRolseArray.java
Note: When reading the program, you do not need to care about the related table structure, you can only care about the entire call processing process.
package com.inberkong.processBean;
import java.lang.*;
import java.sql.*;
import java.util.*;
import java.io.*;
import com.inberkong.util.DataBaseConnection;
public class GetUserRolseArray
{
private Connection conss;
private Statement stmtsss=null;
private Statement stmt2=null,stmt3=null;
private ResultSet rstsss=null;
private ResultSet rst2=null,rst3=null;
Private String sqlss="";
Private String sql2="",sql3="";
Private String rString="";
Private String ID,ID2;
Private String NAME;
private int i=0;
public GetUserRolseArray()
{
try
{
This.conss=DataBaseConnection.getConnection();
}
catch(Exception e)
{
}
//DataBaseConnection.getConnection();
}
protected void finalize() throws Throwable
{
//
//super.finalize();
//System.out.println("inberkong");
closeCON();
}
public String getUserRolseArray() throws Exception
{
//exePtempfunction();
sqlss="SELECT ID,NAME FROM ADMIN WHERE 1=1 AND STATE!=0 AND USERTYPE!=0
ORDER BY ID DESC";
//External users do not participate in post-added role management
stmtsss=conss.createStatement();
rstsss=stmtsss.executeQuery(sqlss);
While (rstsss.next())
{
ID=rstsss.getString("ID");
ID2=ID;
NAME=rstsss.getString("NAME");
rString=rString+"
"+"arr["+i+"]=new BDSort
("+ID+",00,"+NAME+",);";
i++;
sql3="select ID,NAME from ROLE_MANAGE where ID in( select ROLSEID
from USER_ROLSE_LINK where USERID="+ID2+") order by ID asc ";
stmt3=conss.createStatement();
rst3=stmt3.executeQuery(sql3);
while(rst3.next())
{
ID=rst3.getString("ID");
NAME=rst3.getString("NAME");
rString=rString+"
"+"arr["+i+"]=new BDSort
("+ID+","+ID2+","+NAME+",y);";
i++;
}
sql2="select ID,NAME from ROLE_MANAGE where ID not in(select
ROLSEID from USER_ROLSE_LINK where USERID="+ID2+") order by ID asc ";
stmt2=conss.createStatement();
rst2=stmt2.executeQuery(sql2);
while(rst2.next())
{
ID=rst2.getString("ID");
NAME=rst2.getString("NAME");
rString=rString+"
"+"arr["+i+"]=new BDSort
("+ID+","+ID2+","+NAME+",n);";
i++;
}
}
rstsss=null;
return rString;
}
public static void main(String[] args){
//测试如下
GetUserRolseArray obj1 = new GetUserRolseArray();

PHP remains important in modern web development, especially in content management and e-commerce platforms. 1) PHP has a rich ecosystem and strong framework support, such as Laravel and Symfony. 2) Performance optimization can be achieved through OPcache and Nginx. 3) PHP8.0 introduces JIT compiler to improve performance. 4) Cloud-native applications are deployed through Docker and Kubernetes to improve flexibility and scalability.

PHP is suitable for web development, especially in rapid development and processing dynamic content, but is not good at data science and enterprise-level applications. Compared with Python, PHP has more advantages in web development, but is not as good as Python in the field of data science; compared with Java, PHP performs worse in enterprise-level applications, but is more flexible in web development; compared with JavaScript, PHP is more concise in back-end development, but is not as good as JavaScript in front-end development.

PHP and Python each have their own advantages and are suitable for different scenarios. 1.PHP is suitable for web development and provides built-in web servers and rich function libraries. 2. Python is suitable for data science and machine learning, with concise syntax and a powerful standard library. When choosing, it should be decided based on project requirements.

PHP is a scripting language widely used on the server side, especially suitable for web development. 1.PHP can embed HTML, process HTTP requests and responses, and supports a variety of databases. 2.PHP is used to generate dynamic web content, process form data, access databases, etc., with strong community support and open source resources. 3. PHP is an interpreted language, and the execution process includes lexical analysis, grammatical analysis, compilation and execution. 4.PHP can be combined with MySQL for advanced applications such as user registration systems. 5. When debugging PHP, you can use functions such as error_reporting() and var_dump(). 6. Optimize PHP code to use caching mechanisms, optimize database queries and use built-in functions. 7

The reasons why PHP is the preferred technology stack for many websites include its ease of use, strong community support, and widespread use. 1) Easy to learn and use, suitable for beginners. 2) Have a huge developer community and rich resources. 3) Widely used in WordPress, Drupal and other platforms. 4) Integrate tightly with web servers to simplify development deployment.

PHP remains a powerful and widely used tool in modern programming, especially in the field of web development. 1) PHP is easy to use and seamlessly integrated with databases, and is the first choice for many developers. 2) It supports dynamic content generation and object-oriented programming, suitable for quickly creating and maintaining websites. 3) PHP's performance can be improved by caching and optimizing database queries, and its extensive community and rich ecosystem make it still important in today's technology stack.

In PHP, weak references are implemented through the WeakReference class and will not prevent the garbage collector from reclaiming objects. Weak references are suitable for scenarios such as caching systems and event listeners. It should be noted that it cannot guarantee the survival of objects and that garbage collection may be delayed.

The \_\_invoke method allows objects to be called like functions. 1. Define the \_\_invoke method so that the object can be called. 2. When using the $obj(...) syntax, PHP will execute the \_\_invoke method. 3. Suitable for scenarios such as logging and calculator, improving code flexibility and readability.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Atom editor mac version download
The most popular open source editor

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

SublimeText3 Chinese version
Chinese version, very easy to use

WebStorm Mac version
Useful JavaScript development tools

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft