Installing Joomla on Ubuntu

Joomla, Ubuntu

I’m redesigning my portfolio site and decided to use Joomla. I just installed it on my Ubuntu box. It wasn’t difficult, but it could have been easier.

First I downloaded Joomla from here. I had the option of download a nightly build, but I wanted the latest stable version.

Continue reading

Checkout My New Site - T-shirts For Geeks

MySQL: Table Creation Date

MySQL

I recently received an email from one of my clients regarding an error that she was getting on her website. It was a missing table error. I had made some changes over a month ago which required me to add a ‘states’ table. It was interesting because I knew that I had uploaded the table to her server and tested the new functionality.

I then remembered that the host provider had recently upgraded their servers (I use the same host provider). I ran into problems after the upgrade. Any changes that I had made on my site during the time of the upgrade were not reflected on the new server. I had draft posts that were no longer stored in the MySQL database.

To make a long story short (too late), I needed to test whether I created the ‘states’ table during the same time frame as the upgrade. Because I always make and test changes on my computer prior to uploading to a server, I decided to query the table schema on my computer to find out when I created the states table. I knew that MySQL stores database, table, table columns (etc) in the information_schema database. I just wasn’t sure which table the information would be stored in. After a quick search, I found a TABLES table, but I did not know which field to query to find the creation date:

SELECT column_name 
FROM INFORMATION_SCHEMA.COLUMNS 
WHERE table_name = 'TABLES'

This gave me a list of field names in the TABLES table. I found the field CREATE_TIME.

SELECT create_time
FROM INFORMATION_SCHEMA.TABLES
WHERE table_schema = 'arrowcollegiatetour'
AND table_name = 'states'

I found that I created the ‘states’ table during the same time frame as the server upgrades, so I sent my client a message telling her to contact the host provider and have them recreate her site from their daily backups. I just love MySQL.

Checkout My New Site - T-shirts For Geeks

Setting up Ubuntu for Web Development

Ubuntu

I’ve developed in the Windows environment for most of my career.  About 4-5 years ago I began to migrate to the Mac. Now my Mac is my primary computer.

I recently worked on a project where the target OS is linux, so I installed Ubuntu 9.04 desktop on an old PC. The following are the steps I took to create a web development box. This post assumes that you have already installed Ubuntu. Click here or here for installation instructions.

After you have installed ubuntu, you may want to select/download a theme for your box. Click Install Instructions to learn how to install gnome themes.

First, I will set up LAMP (Linux, Apache, MySQL, PHP) and phpMyAdmin. AMP is my default web development environment, regardless of OS.

Next, I will install Python, Django, PostgreSQL, phppgadmin, and pgAdmin (needed for my new project).  I will also install Aptana Studio and Java (need JRE to run Aptana). I have been using Aptana Studio on my Mac for over a year, and it has become my default development IDE.

Continue reading

Checkout My New Site - T-shirts For Geeks

Using CodeIgniter to get the Last Inserted ID

Codeigniter

I often need to know the id of the last inserted record into a table. In the past, I’ve used a PHP function:

function getLastInserted($table, $id) {
	$query = "SELECT $id as maxID from $table where $id = LAST_INSERT_ID()";
	$result = $this->runQuery($query);
	$row = mysql_fetch_row($result);
	return $row[0];
 }

To duplicate this using CodeIgniter’s Active Record, I could write:

function getLastInserted($table, $id) {
	$this->db->select_max($id);
	$Q = $this->db->get($table);
	$row = $Q->row_array();
	return $row[$id];
 }

But, I learned that there is an even faster way that uses one of CodeIgniter’s Helper functions. Immediately after a record has been inserted into the database, I simply call:

$id = $this->db->insert_id();

Although, I am not sure how CodeIgniter knows which field is the primary key, it seems to work.

Checkout My New Site - T-shirts For Geeks