Selecting rows from the database using ADOdb

In the following example, I am going to query a MySQL table, loop through the results, and print them out to the screen, using PHP and ADOdb.

For the example, I have a table called “tablea”, which has two columns, “id” and “description”.

Also, $db is the database connection, for the avoidance of any doubt.

$result = $db->Execute("select id, description from tablea");
 if ($result === false) die("failed");
 while (!$result->EOF) {
	
     echo " <p>.$result->fields['id']." - ".$result->fields['description']." </p>";   
     
	$result->MoveNext();
	
 }

If you want to use ADOdb’s result caching system, the following change to line one will cache the results for 300 seconds.

$result = $db->CacheExecute(300,"select id, description from tablea");

Starting, stopping, or restarting MySQL

Starting or stopping MySQL in Linux (CentOS)

service mysqld start
service mysqld stop
service mysqld restart

Restarting MySQL should only take a second or so. I would be surprised if many of your users noticed that you did it. In saying that, don’t do it unless you have spare time to deal with a failure to restart. You might have made a mistake in the config file and that can stop MySQL starting again.

Your database might appear slower immediately following a restart. This is normal, because you have lost all your cached data/queries. You shouldn’t experience too much of a slow down, but it’s worth noting, just in case.