Slow response (PHP MYSQL)

Asked

Viewed 517 times

-1

<?php

require('DB.class.php');


//$conexao = mysql_connect('xxx.xxx.xxx.xxx','base_dados','utilizador');

//$db      = mysql_select_db('base_dados',$conexao);


$SQl_list = DB::getConn()->prepare("SELECT * FROM `wpr3_posts` WHERE post_content LIKE '%perfil.mercadolivre.com.br/MARCH+GOLD%'");

$SQl_update = DB::getConn()->prepare("UPDATE `wpr3_posts` SET  `post_content` = ? WHERE ID = ?");

$SQl_list -> execute();

var_dump( DB::getConn());

while ($res = $SQl_list->fetch(PDO::FETCH_ASSOC)){
    $h    = str_replace('https://perfil.mercadolivre.com.br/MARCH+GOLD', 'http://perfil.mercadolivre.com.br/MARCH+GOLD', $res['post_content']);

    $SQl_update -> execute(array($h,$res['ID']));
}

This code is not mine, the problem is that with this coding the site in general became slow, I would like to know what the problem is and how I can fix it. I was told that the problem is also that it overwritten too many images that were not to be replaced, probably it pulled too many images than it should and now to load the database, it got complicated. Thanks in advance!

  • How many records in the table?

2 answers

1

Friend, this technology has been obsolete since PHP version 5 and has been removed with version 7. I recommend using the mysqli or PDO library for connection to the database using PHP.

  • 1

    Apparently he’s using PDO indirectly through class DB. Note that obsolete functions are commented on in the code and therefore are not actually being used.

0

One of the ways to improve access is to use SELECT * is to name the fields. Review the obsolete technologies, they also delay the code. Review the file DB.class.php to see how the connection is being made.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.