Monday, March 3, 2014

How to DB over ZF2

The model used to DB in ZF2 is PDO.
PDO helps to transform a database to Objects.

The PHP Data Objects (PDO) extension defines a lightweight, consistent interface for accessing databases in PHP. Each database driver that implements the PDO interface can expose database-specific features as regular extension functions. Note that you cannot perform any database functions using the PDO extension by itself; you must use a database-specific PDO driver to access a database server.

PDO provides a data-access abstraction layer, which means that, regardless of which database you're using, you use the same functions to issue queries and fetch data. PDO does not provide a database abstraction; it doesn't rewrite SQL or emulate missing features. You should use a full-blown abstraction layer if you need that facility.


DB in ZF2 , we call MODEL
USING ZFTOOLS 

Thursday, February 27, 2014

Routing and controllers over ZF2


In the Zend Framework 1 Bibel "Zend Framework 1.8 Web Application Development" by Keith Pope the ZF1 request handling is described as follows:
The process can be broken down like this:
  1. A request is made and the Request Object is created.
  2. The routeStartup event is fired.
  3. The Router processes the request.
  4. The routeShutdown event is fired.
  5. The dispatchLoopStartup event is fired.
  6. The dispatch loop is started.
  7. The preDispatch event is fired.
  8. The Dispatcher calls the Action Controller.
  9. The Action Controller writes to the Response Object.
  10. The postDispatch event is fired.
  11. If there are actions left to call, then go to Step 7.
  12. The dispatchLoopShutdown event is fired.
  13. The Response is sent back.


zf2.


The mapping of a URL to a particular action is done using routes that are defined in the module’s module.config.php


The default route configured is to accept any url of this format, this is the standard format
mydomain.com/
mydomain.com/applicatiom/controller/action (standard format)
in your case mydomain.com/otheraction the router expect a module otheraction, but its not present.
if you need to have a route as specified above have a entry under route
'otheraction' => array(
    'type' => 'Zend\Mvc\Router\Http\Literal',
    'options' => array(
        'route'    => '/otheraction',
        'defaults' => array(
            'controller' => 'Application\Controller\Index',
            'action'     => 'otheraction',
        ),
    ),
),


http://framework.zend.com/manual/2.0/en/user-guide/routing-and-controllers.html

Monday, February 17, 2014