Mostrando las entradas con la etiqueta hack. Mostrar todas las entradas
Mostrando las entradas con la etiqueta hack. Mostrar todas las entradas

20130425

Loading modules in Zend Framework 2 for the lazy (only for Development purposes)

When you are developing modules for ZF2, you have to add your model name manually to the application.config.php file:

If you want to "load" your module without doing this (use this only for development!!! not in production!!!) you can hack the application.config.php to construct the array with the modules in your filesystem.

This will read your modules directory and fill the configuration array with them. Just a quick hack!

When deploying to production just add your production modules in the original config array and its ready to work.

Update:
As Manuel Stosic pointed out in the ZF2 group in facebook, this is not a good approach if you you need to preserve loading order. This is intended to be use in your own modules while developing (i use this approach with a dev partner), if you are going to use zfcUser, etc... just put those modules in the original config array.

20111109

Throw a 404 in Zend Framework

This is very easy, just throw an exception in the controller action:


This will generate a 404 page using the ErrorController.

20110604

Removing duplicate rows in mysql

In our recent project called Sfter we have a deamon that do a lot of inserts in a mysql table.
It had a bug that duplicate those rows a LOT! (more than 300 times every record)... today morning i realized we had around 3millon records in that table DAMN!.

So i have to figure out how to remove those duplicates directly using some SQL commands.



From the Mysql manual:


  • IGNORE is a MySQL extension to standard SQL. It controls how ALTER TABLE works if there are duplicates on unique keys in the new table or if warnings occur when strict mode is enabled. If IGNORE is not specified, the copy is aborted and rolled back if duplicate-key errors occur. If IGNORE is specified, only the first row is used of rows with duplicates on a unique key, the other conflicting rows are deleted. Incorrect values are truncated to the closest matching acceptable value.


Pretty simple eh!