Give MySQL or PHP work?

I have several PHP codes to do the tasks MySQL could do.

for example, sorting, combining data from different MySQL tables, etc.

Recently, I found out that I can do all these things with a single MySQL query.

I am wondering if it is better to provide MySQL-compatible MySQL or PHP jobs. efficiency, speed, etc.

Thank,

+3
source share
6 answers

If you do this in PHP, you simply reprogram those functions that MySQL already has. This is far from the most optimized solution, and therefore it is much slower.

You must do this in the SQL query.

+2
source

, MySQL .

+2

MySQL. -, . , , .

+2

. , PHP

MySQL String .

MySQL.

+2

MySQL. , . PHP .

+1

: MySQL. -, , ( ). . :

$query = "SELECT DISTINCT post.title as title, post.id as id, 
                    product.imageURL as imageURL, product.dueDate as dueDate 
                    FROM post, product 
                    WHERE post.status='saved'  
                    AND post.productURL=product.linkURL 
                    AND post.userEmail='$session[userEmail]' 
                    AND NOT EXISTS(
                        SELECT publication.postId FROM publication 
                        WHERE publication.postId=post.id
                        ) 
                    ORDER BY post.id";

, . , post.productURL = product.linkURL. , , , , - , . , MySQL.

, , . .

+1

Source: https://habr.com/ru/post/1756400/


All Articles