Archive for the ‘Zend framework’ Category

Raw query on Zend framework

\Zend_Db_Table_Abstract::getDefaultAdapter()->query($sql); \Zend_Db_Table_Abstract::getDefaultAdapter()->query($sql)->fetch(); //if you need to fetch results if it does not work, use the db handler Pdo), and call – for example – exec() \Zend_Db_Table_Abstract::getDefaultAdapter()->getConnection()->exec($sql);

How to use Zend Framework hostname and chain routes to map a module (e.g. admin area) to a different subdomain.

In addition to the standard Static, Route and Regex routes, Zend Framework implements two more less famous – but useful – ones: hostname and chain routes. The first one works with the subdomain (instead of the path) and it can be instantiated with some default parameters (e.g.  ”module”=>”admin”). It’s possible to specify a variable in the [...]

My considerations about Db models and RESTful application

I’ve worked on more than one project using complicate DB layers and HTTP client/server systems (e.g. RESTful apps) to interface with the DB server. My opinion: when working on a project (especially a team project), easy solutions are better then clever ones. OK, OK, a design pattern is an elegant solution to a common problem, [...]

ZFDebug panel quick tutorial

In this post I’ll just write some notes to install the ZFDebug panel for Zend Framework. That’s basically a front controller plugin that displays at the bottom of the layout (slides from the bottom), contains “debug panels” (cache, variables, zend db, time info etc…) and it’s easy to extend. Copy libraries and images Grab the [...]

Display full query in the Exception of Zend_Db_Statement_Pdo

When there is a SQL error, Zend DB Statement PDO just prints the error without including the query. Zend_Db_Statement_Exception: SQLSTATE[42000]:  Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘) ORDER BY `order` [...]

Optimising Zend Framework applications (2) – cache pages and PHP accelerator [updated]

[continue from previous post] 4. Use an op-code cache/accelerator (Apc, XCache) PHP is very fast but it’s not compiled. A op-code cache helps. See this comparison as an example of what could be the performance increase. That does not mean we can skip the other optimisation, code bottlenecks should be removed anyway. Optimising code is [...]

Optimising Zend Framework applications (1) – cache db objects, PHP code profiling and optimisation

I’m optimizing some zend framework applications these days and I’ve been reading, researching, optimising and measuring results. Some links to read before: Optimising a Zend Framework application – by Rob Allen – PHPUK February 2011 Profile your PHP application and make it fly – by Lorenzo Alberton – PHPNW 9 Oct 2010 The optimisation process [...]

Command line tool for CRUD (Zend Framework scaffolding libraries)

I’ve created a command line tool for my scaffolding zend framework libraries. Those libraries are basically abstract related classes (Controller, Form, DbTable, Filter and Order forms) that contains all the logic to make CRUD (Create, Read, Update, Delete) forms for admin area. Thanks to those libraries, a complete CRUD logic requires only a few lines [...]

Automatic caching of Zend_Db (or any object) calls

I’m working on a personal Zend framework application that uses Zend_Db_Table_Abstract classes to get data from the database. Each class has its own methods (getall, getXX, getYYY) etc… My need was having all those method calls (around the code) automatically cached. The first solution in my mind was a general wrapper (container) class that uses [...]

Zend router with Zend Translate: default locale region issues (updated)

Let’s say we have a zend TMX translator $routeTranslator = new Zend_Translate( ‘tmx’, ‘/path/to/tmxFiles/’, ‘en_GB’ ); Zend_Controller_Router_Route::setDefaultTranslator($routeTranslator); With this entry archive archive-all archivio Now, lt’s add the route with translated segment. $route = new Zend_Controller_Router_Route( ‘@archiveroute’, array( ‘controller’ => ‘archive’, ‘action’ => ‘index’ ) ); If the application locale is en_GB, the dispatch of the [...]