Tag Archives: Zend Framework2

Zend Framework2: Tutorial Part4: Building a CRUD app by using Table Gateway1

The previous post I already wrote how to add a references to the databases connection, this post I will tell you how to building a CRUD app.

First, create a new module named “CsnUser”, or just copy the entire “Application” fold, and change the name to “CsnUser” .

then you file struction should look like this.

crud1

Second, go to open your Module.php

Here is the code:inside it quick just standard proceed, just tell where is the config file and  the namespace’s path.

<?php

namespace CsnUser;//this namespace must match your module’s name

class Module
{
public function getConfig()
{
return include __DIR__ . ‘/config/module.config.php’;
}

public function getAutoloaderConfig()
{
return array(
‘Zend\Loader\StandardAutoloader’ => array(
‘namespaces’ => array(
__NAMESPACE__ => __DIR__ . ‘/src/’ . __NAMESPACE__,
),
),
);
}

}

Continue reading Zend Framework2: Tutorial Part4: Building a CRUD app by using Table Gateway1

Advertisements

Zend Framework2: Tutorial Part3 use TableGateway add references to the database connection

Just go to modify “config/autoload/global.php”

return array(
‘db’ => array(
‘driver’ => ‘Pdo’,
‘dsn’ => ‘mysql:dbname=test;host=localhost’,
‘username’ => ‘db_user’,
‘password’ => ”,
‘driver_options’ => array(
PDO::MYSQL_ATTR_INIT_COMMAND => ‘SET NAMES \’UTF8\”
),
),
‘service_manager’ => array(
‘factories’ => array(
‘Zend\Db\Adapter\Adapter’
=> ‘Zend\Db\Adapter\AdapterServiceFactory’,
),
),
);