Use column alias in conditions

With the use of HAVING you can use a result columns of a database query in itself: SELECT category_field = 3 AS ‘result’ FROM catalog_category_entity WHERE condition_field = 985 HAVING result = 1; Here the alias result (see AS ‘result’) for the only column is used as a condition with HAVING. That is by now […]

Debug database queries with parameters

Sometimes you have to query the database directly in your module. In these situations you can use the placeholder feature of the Zend_Db_Statement component. :placeholder will be replaced by the respective value when calling fetch on a Zend_Db_Adapter_Mysqli instance with an array of replacements for example. If you need to debug the query with all parameters in it, […]