HTML table with ezSQL

When writing an application in PHP, I like to use Justin Vincents ezSQL for database access. ezSQL allows you to write your query and get your results as a PHP object, as shown in the following example:

// Select multiple records from the database and print them out..
$users = $db->get_results("SELECT name, email FROM users");
 
foreach ( $users as $user )
{
            // Access data using object syntax
            echo $user->name;
            echo $user->email;
}

So one common task you might want to do is to present the retrieved result as a table. While the ezSQL library features a debug() method, this should obviously only be used during development. So if you want to display your result as a table, you’ve got to do it yourself and I hereby provide a snippet of code on how to do it…

So after you’ve fetched your result from the database you can use the following method to print a HTML table with your results:

Read the rest of this entry

XCache – A booster for WordPress

I was not pleased with the results of my database tweaks. So I looked further to improve the performance of this blog and stumbled upon XCache. Developed by the same people that created lighttpd, XCache is a PHP opcode cacher that greatly improves WordPress performance.

Using the same Java program I used in my previous tests, I queried the website 500 times and packed the data into a graph. This is what showed up:

Graph showing xcache performance impact

Now that is what I am talking about! The query time is nearly three times as fast as before.

I am still looking into other cachers like Alternative PHP Cache (APC), but I like xcache so far.

WordPress MySQL Permissions

Having security in mind, I had some concerns granting all privileges to the WordPress MySQL user (see the instructions from WordPress):

GRANT ALL PRIVILEGES ON databasename.* TO "wordpressusername" [..]

After all, with these privileges the WordPress user would be able to access other databases on this server and do whatever he likes. WordPress has become very popular and is a known target for exploits and the like (as a quick search on milw0rm.com will confirm). I didn’t like that idea.

So here is what I did:

GRANT SELECT, INSERT, UPDATE, CREATE, DELETE ON wordpress.* TO 'wordpress' IDENTIFIED BY 'mypass';

This works fine so far and I don’t think my WordPress installation needs more privileges. Note that the ALTER and DROP statements are missing from my list, which could interfere with future updates. But we’ll see…

Hello world!

Welcome to WordPress. This is your first post. Edit or delete it, then start blogging!

Thank you, very kind. Let’s see what we have here…

Today I finally received the credentials for my new rootserver from HostEurope. So far everything went well and quickly I was able to set up a webserver.

So far, so good. I am going to post some more content in the following days.

Hello world

My name is Simon Krenger, I am a Technical Account Manager (TAM) at Red Hat. I advise our customers in using Kubernetes, Containers, Linux and Open Source.

Elsewhere

  1. GitHub
  2. LinkedIn
  3. GitLab