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

MantisBT timezone warning (date_default_timezone_get)

For a proof-of-concept, I had to install a new Mantis Bug Tracker instance and after finishing the installation, the login screen greeted me with the following warning:

SYSTEM WARNING: date_default_timezone_get(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'UTC' for 'UTC/0.0/no DST' instead

The solution is amazingly simple. The only thing that I needed to find out was that this is a PHP error and not a MantisBT error. So after that was settled, I went on and just followed the instructions given by the warning:

Read the rest of this entry

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