I put together a simple script that pulls the product name, category name and product id from two tables. Then I take that data and use it to create a page title that’s better than what I currently have for SEO purposes. For some reason I didn’t think it would take as long as it’s taking to run. There are 7k products.
My hosting company does allow the creation of a custom php.ini so I was able to override the 30 second time limit and changed it to 6000. But still the script times out. So I thought my script my suck. 🙂
Below is the script. Is there a better way I could write this so it doesn’t time out? Or is what I’m trying to do just going to take some time and I need to write the script to do one category at a time?
<?php
// Make a MySQL Connection
mysql_connect("localhost", "myusername", "mypassword") or die(mysql_error());
mysql_select_db("mydatabase") or die(mysql_error());
$result = mysql_query("SELECT isc_products.prodcode, isc_products.prodname, isc_categories.catname FROM isc_products, isc_categories WHERE isc_products.prodcatids = isc_categories.categoryid")
or die(mysql_error());
while($row = mysql_fetch_array($result)){
$pname = mysql_real_escape_string($row['prodname']);
$catname = mysql_real_escape_string($row['catname']);
$sitename = Sitename;
$prodcode = $row['prodcode'];
$result2 = mysql_query("UPDATE isc_products SET prodpagetitle = '$pname - $catname - $sitename' WHERE prodcode = '$prodcode'")
or die(mysql_error());
}
?>
indexes http://www.threewestcreative.com/indexes.jpg
Thanks, your help is appreciated. 🙂
Thanks SO much everyone! I really appreciate the quick responses. I can’t believe I overlooked something so simple as running a direct query against the database (without php). Geez… Thanks again!
Just run
If it times out, your DB is fishy (missing indices?)