Testing Codeigniter with Firebird

I’ve been using Codeigniter as my development platform and framework of choice since last year. Being a ten year PHP developer, Codeigner was a refreshing way of coding web apps with PHP.

The first ones developments I did with Codeigniter were using MySQL, a very used database. But since I’ve also been using Firebird SQL Database from ten or more years ago, I decided to give a try to the Codeigniter-Firebird duo.

So I downloaded the Firebird drivers for Codeigniter, written by Carlos Garcia, and installed in my Codeigniter application setup.

Everything went ok, in the first attempts to make a connection and display a table, the data was displayed as expected. But I noted some little differences in using Firebird, here’s the list:

a) You must use the array indexes of the result array of a query in capital letters. For instance, in this code:

 $arr = $this->db->query("select id, field from table");
$data = $arr->result_array(); 

When you refer to the content of the data array, you should do that in this way:

echo $data[0]['ID']; 

By the way, in the query statement, you can use lower or uppercase letters.

NOTE: Still have not used the ActiveRecord Get methods that return objects for each row of the table, I’ll report them as soon as I use them.

b) When a query fetches a lot of records (sorry, I didn’t test the exact number), it throws an http ‘Internal server 500’ message. I also didn’t test if it’s my server setup. As I know I’ll be using pagination, the error disappeared when I used a 20 record page pagination in the display of the table.

c) I also had an error when making a SELECT * FROM TABLE statement, and if that table has a very large VARCHAR (or CHAR) fields. This was fixed when I specified only a few fields of the table.

d) Another thing I noted is that the num_rows method of a query always returns 1. Don’t know if it’s a bug or product of a special condition in my program. This was resolved by using the sizeof function of PHP, applying it to the result array. This way I know how many rows returned the query.

These are the things I have observed so far. I did my testing today, and plan to continue the application. I’ll report these issues to Carlos, and as he lives in the same city than I, maybe I’ll thank him (in the name of all Codeigniter/Firebird developers) his time and effort in development this piece of software with a pair of beers (maybe more).

Apart from these little issues, the Firebird driver for Codeigniter is working very well and it’s very nice to make web applications with both development softwares.

You can download the Firebird Driver for Codeigniter in this URL:

Configurando Codeigniter para desarrollo en 10 minutos en Mac OSX

A continuación mostraré una manera rápida de tener un entorno de desarrollo Codeigniter, ya se para crear desarrollos o para aprender, todo esto en 10 minutos (dependiendo obviamente de la velocidad de descarga que tengas).

  • 1.- Descarga MAMP de la dirección http://www.mamp.info

  • 2.- Descarga el editor Aptana Studio desde la dirección: http://aptana.com

  • 3.- Descarga el administrador de MySQL Sequel Pro desde: http://www.sequelpro.com

  • 4.- Descargar la versión más reciente de Codeigniter: http://codeigniter.com

  • 5.- Instalar MAMP, Aptana Studio y Sequel Pro.

  • 6.- Crear una carpeta de desarrollo (puede ser en Documentos (documents) en nuestra Mac)

  • 7.- Iniciar MAMP, escribir la contraseña de administrador para que inicien los servidores (MySQL y Apache).

  • 8.- Detener los servidores, y cambiar la configuración (botón Preferencias…) poner los puertos 80 en Apache y 3306 en MySQL. En la pestaña Apache, seleccionar la carpeta creada en el punto 6. Dar click en OK.

Haga Clic para ver la Imagen original en una ventana nueva
9.- Reiniciar los servidores (punto 7).
10.- Desempaquetar Codeigniter en la carpeta de desarrollo.
11.- Abrir el archivo database.php que se encuentra en la carpeta Applications/Config de Codeigniter
12.- Modificar las líneas de configuración:

$db['default']['hostname'] = 'localhost';
$db['default']['username'] = 'root';
$db['default']['password'] = 'root';
$db['default']['database'] = 'ejemplo';
$db['default']['dbdriver'] = 'mysql';

Donde la línea que indica la base de datos, debe contener el nombre de una base de datos a crear.
13.- Crear la base de datos “ejemplo”, usando Sequel Pro, conectándose al servidor con estas configuraciones:
Haga Clic para ver la Imagen original en una ventana nueva

14.- Una vez conectado, y utilizando el botón Choose Database, seleccionar la opción Add Database.
Haga Clic para ver la Imagen original en una ventana nueva
15.- Escribir el nombre de la base de datos (en este caso, ejemplo).
16.- Listo, ya tenemos un entorno para una aplicación Codeigniter. Lo siguiente es crear modelos, controladores y vistas.